Skip to content

Commit

Permalink
fix debounce
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Xiong committed Nov 12, 2024
1 parent 24b46c3 commit 2ca9cc3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ export default class ObsidianGoogleDrive extends Plugin {
return this.saveData(this.settings);
}

debouncedSaveSettings() {
debounce(() => this.saveSettings(), 1000, true);
}
debouncedSaveSettings = debounce(this.saveSettings.bind(this), 500, true);

handleCreate(file: TAbstractFile) {
if (this.settings.operations[file.path] === "delete") {
Expand All @@ -152,7 +150,10 @@ export default class ObsidianGoogleDrive extends Plugin {
}

handleModify(file: TFile) {
if (this.settings.operations[file.path] === "create") return;
const operation = this.settings.operations[file.path];
if (operation === "create" || operation === "modify") {
return;
}
this.settings.operations[file.path] = "modify";
this.debouncedSaveSettings();
}
Expand Down

0 comments on commit 2ca9cc3

Please sign in to comment.