Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(save_indicator): indicate errors
Elian Doran5f1486168258
diff --git a/apps/client/src/services/spaced_update.ts b/apps/client/src/services/spaced_update.tsindex 1347d37572..253cab63c4 100644--- a/apps/client/src/services/spaced_update.ts+++ b/apps/client/src/services/spaced_update.ts@@ -1,4 +1,5 @@import type { SaveState } from "../components/note_context";+import { getErrorMessage } from "./utils";type Callback = () => Promise<void> | void;@@ -38,7 +39,8 @@ export default class SpacedUpdate {this.stateCallback?.("saved");} catch (e) {this.changed = true;-+ this.stateCallback?.("error");+ logError(getErrorMessage(e));throw e;}}@@ -68,15 +70,20 @@ export default class SpacedUpdate {this.updateInterval = interval;}- triggerUpdate() {+ async triggerUpdate() {if (!this.changed) {return;}if (Date.now() - this.lastUpdated > this.updateInterval) {this.stateCallback?.("saving");- this.updater();- this.stateCallback?.("saved");+ try {+ await this.updater();+ this.stateCallback?.("saved");+ } catch (e) {+ this.stateCallback?.("error");+ logError(getErrorMessage(e));+ }this.lastUpdated = Date.now();this.changed = false;} else {diff --git a/apps/client/src/widgets/layout/NoteBadges.tsx b/apps/client/src/widgets/layout/NoteBadges.tsxindex 9d19a5b158..bdb334684d 100644--- a/apps/client/src/widgets/layout/NoteBadges.tsx+++ b/apps/client/src/widgets/layout/NoteBadges.tsx@@ -141,7 +141,7 @@ function SaveStatusBadge() {return (<Badge- className={clsx("save-status-badge", saveState)}+ className={clsx("save-status-badge", saveState.state)}icon={icon}text={title}tooltip={tooltip}