diff --git a/apps/client/src/services/spaced_update.ts b/apps/client/src/services/spaced_update.ts index 1347d3757..253cab63c 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; @@ -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.tsx index 9d19a5b15..bdb334684 100644 --- a/apps/client/src/widgets/layout/NoteBadges.tsx +++ b/apps/client/src/widgets/layout/NoteBadges.tsx @@ -141,7 +141,7 @@ function SaveStatusBadge() { return (