Skip to content

Commit

Permalink
fix: add debounce to avoid parallel executions
Browse files Browse the repository at this point in the history
  • Loading branch information
badrbouslikhin committed Feb 26, 2021
1 parent bdb3ad1 commit 43b9b89
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Plugin,
PluginSettingTab,
Setting,
debounce,
TFile,
} from "obsidian";
import type moment from "moment";
Expand Down Expand Up @@ -38,7 +39,11 @@ export default class Changelog extends Plugin {
hotkeys: [],
});

this.watchVaultChange = this.watchVaultChange.bind(this);
this.watchVaultChange = debounce(
this.watchVaultChange.bind(this),
200,
false
);
this.registerWatchVaultEvents();
}

Expand All @@ -54,11 +59,11 @@ export default class Changelog extends Plugin {
}
}

async watchVaultChange(file: any) {
watchVaultChange(file: any) {
if (file.path === this.settings.changelogFilePath) {
return;
} else {
await this.writeChangelog();
this.writeChangelog();
}
}

Expand Down

0 comments on commit 43b9b89

Please sign in to comment.