Skip to content

Build your personal knowledge base with Trilium Notes

client/debouncer: report pending updates before destroying

Adorian Doranc25859cee9d2
diff --git a/apps/client/src/utils/debouncer.ts b/apps/client/src/utils/debouncer.ts
index b37c4118a7..9057d039fe 100644
--- a/apps/client/src/utils/debouncer.ts
+++ b/apps/client/src/utils/debouncer.ts
@@ -14,12 +14,15 @@ export default class Debouncer<T> {
updateValue(value: T) {
this.lastValue = value;
- this.destroy();
+ if (this.timeoutId !== null) {
+ clearTimeout(this.timeoutId);
+ }
this.timeoutId = setTimeout(this.reportUpdate.bind(this), this.debounceInterval);
}
destroy() {
if (this.timeoutId !== null) {
+ this.reportUpdate();
clearTimeout(this.timeoutId);
}
}