From e2a965e3d6c29e4b8bcf460995c45ff1444c16fe Mon Sep 17 00:00:00 2001 From: Jiaxin Peng Date: Sat, 1 Nov 2025 00:32:35 +0000 Subject: [PATCH] fix: update autoSyncTimeout type and ensure window context for setTimeout calls --- src/main.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index 134e2d7..3d34a81 100644 --- a/src/main.ts +++ b/src/main.ts @@ -13,7 +13,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin { commands: ribbonCommands; app: App; modifyEventRef: EventRef | null = null; - autoSyncTimeout: NodeJS.Timeout | null = null; + autoSyncTimeout: number | null = null; private syncingFiles: Set = new Set(); private lastFrontmatterCache: Map = new Map(); private lastContentHashCache: Map = new Map(); @@ -207,7 +207,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin { // Set a new timeout to trigger sync after user-configured delay (in seconds) const delayMs = (this.settings.autoSyncDelay || 2) * 1000; - this.autoSyncTimeout = setTimeout(async () => { + this.autoSyncTimeout = window.setTimeout(async () => { await this.autoSyncFile(file); }, delayMs); }); @@ -380,7 +380,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin { // After sync completes, update cache with the latest frontmatter (including updated NotionIDs) // Wait a bit for metadata cache to update - setTimeout(async () => { + window.setTimeout(async () => { const updatedFrontmatter = this.app.metadataCache.getFileCache(file)?.frontmatter; const updatedContent = await this.app.vault.read(file); const updatedHash = this.simpleHash(updatedContent);