From 0dafb5c7714a79897ee751e5b820a2089584139f Mon Sep 17 00:00:00 2001 From: Sebastien Dubois Date: Tue, 26 Nov 2024 19:07:17 +0100 Subject: [PATCH] Revert "feat: Enable updates to all files, not just recently modified" This reverts commit 35cbd62f4327c4755cf7b6604bac423173432f9d. --- apps/plugin/src/app/plugin.ts | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/apps/plugin/src/app/plugin.ts b/apps/plugin/src/app/plugin.ts index a9ec9e6..b8b5798 100644 --- a/apps/plugin/src/app/plugin.ts +++ b/apps/plugin/src/app/plugin.ts @@ -52,17 +52,6 @@ export class DataviewSerializerPlugin extends Plugin { true ); - scheduleFullUpdate = debounce( - this.processAllFiles.bind(this), - MINIMUM_MS_BETWEEN_EVENTS * 20, - true - ); - - async processAllFiles(): Promise { - this.app.vault.getMarkdownFiles().forEach((file) => { - this.processFile(file); - }); - } /** * Process all the identified recently updated files */ @@ -183,7 +172,6 @@ export class DataviewSerializerPlugin extends Plugin { this.app.vault.on('create', (file) => { this.recentlyUpdatedFiles.add(file); this.scheduleUpdate(); - this.scheduleFullUpdate(); }) ); @@ -191,7 +179,6 @@ export class DataviewSerializerPlugin extends Plugin { this.app.vault.on('rename', (file) => { this.recentlyUpdatedFiles.add(file); this.scheduleUpdate(); - this.scheduleFullUpdate(); }) ); @@ -199,7 +186,6 @@ export class DataviewSerializerPlugin extends Plugin { this.app.vault.on('modify', (file) => { this.recentlyUpdatedFiles.add(file); this.scheduleUpdate(); - this.scheduleFullUpdate(); }) ); }); @@ -221,16 +207,14 @@ export class DataviewSerializerPlugin extends Plugin { try { //log(`Processing file: ${file.path}`, 'debug'); - const cachedText = await this.app.vault.cachedRead(file); - const foundQueries: string[] = findQueries(cachedText); + const text = await this.app.vault.cachedRead(file); + const foundQueries: string[] = findQueries(text); if (foundQueries.length === 0) { // No queries to serialize found in the file return; } - const text = await this.app.vault.read(file); - // Process the modified file let updatedText = `${text}`; // To ensure we have access to replaceAll... @@ -277,7 +261,7 @@ export class DataviewSerializerPlugin extends Plugin { } // Keep track of the last time this file was updated to avoid modification loops - const nextPossibleUpdateTimeForFile = add(new Date(), { + const nextPossibleUpdateTimeForFile = add(new Date(file.stat.mtime), { seconds: MINIMUM_SECONDS_BETWEEN_UPDATES, }); this.nextPossibleUpdates.set(file.path, nextPossibleUpdateTimeForFile); @@ -324,7 +308,7 @@ export class DataviewSerializerPlugin extends Plugin { file.path )!; - if (isBefore(new Date(), nextPossibleUpdateForFile)) { + if (isBefore(file.stat.mtime, nextPossibleUpdateForFile)) { log('File has been updated recently. Ignoring', 'debug', file.path); return true; } else {