From 2738498dc2243ee1e7f6e973b7dc8feffe4444b9 Mon Sep 17 00:00:00 2001 From: Jiaxin Peng Date: Sat, 1 Nov 2025 00:30:39 +0000 Subject: [PATCH] fix: clean up formatting in auto sync logic for better readability --- src/main.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main.ts b/src/main.ts index a49f5a7..134e2d7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -220,9 +220,9 @@ export default class ObsidianSyncNotionPlugin extends Plugin { // Filter out NotionID-related keys and Obsidian internal keys const isIgnoredKey = (key: string) => { - return key.startsWith('NotionID-') || - key === 'NotionID' || - key === 'position'; // Obsidian's internal metadata + return key.startsWith('NotionID-') || + key === 'NotionID' || + key === 'position'; // Obsidian's internal metadata }; const oldNonNotionKeys = oldKeys.filter(k => !isIgnoredKey(k)).sort(); const newNonNotionKeys = newKeys.filter(k => !isIgnoredKey(k)).sort(); @@ -296,11 +296,11 @@ export default class ObsidianSyncNotionPlugin extends Plugin { // Check if only NotionID fields changed (to avoid sync loops) const lastFrontmatter = this.lastFrontmatterCache.get(file.path); - + if (lastFrontmatter && lastContentHash) { const frontmatterOnlyNotionIDChanged = this.onlyNotionIDChanged(lastFrontmatter, frontMatter); const contentUnchanged = contentHash === lastContentHash; - + console.log(`[AutoSync] Change analysis for ${file.basename}:`, { frontmatterOnlyNotionIDChanged, contentUnchanged, @@ -308,7 +308,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin { contentChanged: !contentUnchanged, willSync: !(frontmatterOnlyNotionIDChanged && contentUnchanged) }); - + // Only skip sync if BOTH conditions are true: // 1. Frontmatter only has NotionID changes (no real user changes) // 2. Content is completely unchanged @@ -319,7 +319,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin { this.lastContentHashCache.set(file.path, contentHash); return; } - + if (!contentUnchanged) { console.log(`[AutoSync] Content changed - will sync`); } else if (!frontmatterOnlyNotionIDChanged) { @@ -384,7 +384,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin { const updatedFrontmatter = this.app.metadataCache.getFileCache(file)?.frontmatter; const updatedContent = await this.app.vault.read(file); const updatedHash = this.simpleHash(updatedContent); - + if (updatedFrontmatter) { this.lastFrontmatterCache.set(file.path, { ...updatedFrontmatter }); this.lastContentHashCache.set(file.path, updatedHash);