diff --git a/application/state/useVaultState.ts b/application/state/useVaultState.ts index 3e6a1f2e4..cbc216db8 100644 --- a/application/state/useVaultState.ts +++ b/application/state/useVaultState.ts @@ -288,6 +288,7 @@ export const useVaultState = () => { const hostsRef = useRef([]); const notesRef = useRef([]); const noteGroupsRef = useRef([]); + const notesPersistFailureNotifiedAtRef = useRef(0); customGroupsRef.current = customGroups; managedSourcesRef.current = managedSources; hostsRef.current = hosts; @@ -611,10 +612,15 @@ export const useVaultState = () => { setNotes(cleaned); publishNotesSnapshot({ notes: cleaned, noteGroups: noteGroupsRef.current }); if (!persisted) { - notify.error( - "Notes could not be saved. Free some local storage space and try again.", - "Notes", - ); + const now = Date.now(); + // Debounced autosave can hit quota repeatedly; avoid toast spam. + if (now - notesPersistFailureNotifiedAtRef.current > 10_000) { + notesPersistFailureNotifiedAtRef.current = now; + notify.error( + "Notes could not be saved. Free some local storage space and try again.", + "Notes", + ); + } return false; } return true; diff --git a/application/state/vaultNotesPersistence.test.ts b/application/state/vaultNotesPersistence.test.ts index 9b4d8a3ed..83f1d9ce6 100644 --- a/application/state/vaultNotesPersistence.test.ts +++ b/application/state/vaultNotesPersistence.test.ts @@ -50,4 +50,6 @@ test("useVaultState updateNotes surfaces storage write failures", () => { assert.match(source, /notify\.error/); assert.match(source, /!persisted|persisted === false/); assert.match(source, /return false/); + assert.match(source, /notesPersistFailureNotifiedAtRef/); + assert.match(source, /10_000/); });