Enhance settings persistence: add error handling for storage operations to ensure in-memory updates are applied even when storage quota is exceeded or restricted.

This commit is contained in:
Val Alexander 2026-03-17 23:14:06 -05:00
parent 2d87bc703f
commit 1e1bc24f80
No known key found for this signature in database
1 changed files with 7 additions and 4 deletions

View File

@ -319,8 +319,11 @@ function persistSettings(next: UiSettings) {
...(next.locale ? { locale: next.locale } : {}),
};
const serialized = JSON.stringify(persisted);
storage?.setItem(scopedKey, serialized);
// Keep the legacy unscoped key in sync for older readers and migration tests,
// but never include the session token in persistent storage.
storage?.setItem(LEGACY_SETTINGS_KEY, serialized);
try {
storage?.setItem(scopedKey, serialized);
storage?.setItem(LEGACY_SETTINGS_KEY, serialized);
} catch {
// best-effort — quota exceeded or security restrictions should not
// prevent in-memory settings and visual updates from being applied
}
}