Skip to content

Commit 43b9b89

Browse files
fix: add debounce to avoid parallel executions
1 parent bdb3ad1 commit 43b9b89

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

main.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
Plugin,
55
PluginSettingTab,
66
Setting,
7+
debounce,
78
TFile,
89
} from "obsidian";
910
import type moment from "moment";
@@ -38,7 +39,11 @@ export default class Changelog extends Plugin {
3839
hotkeys: [],
3940
});
4041

41-
this.watchVaultChange = this.watchVaultChange.bind(this);
42+
this.watchVaultChange = debounce(
43+
this.watchVaultChange.bind(this),
44+
200,
45+
false
46+
);
4247
this.registerWatchVaultEvents();
4348
}
4449

@@ -54,11 +59,11 @@ export default class Changelog extends Plugin {
5459
}
5560
}
5661

57-
async watchVaultChange(file: any) {
62+
watchVaultChange(file: any) {
5863
if (file.path === this.settings.changelogFilePath) {
5964
return;
6065
} else {
61-
await this.writeChangelog();
66+
this.writeChangelog();
6267
}
6368
}
6469

0 commit comments

Comments
 (0)