fix(decoder): connect even when the browser storage is full

A big installation outgrew the localStorage quota; saveState() threw
QuotaExceededError and, since connecting saves first, the decoder never
came online. The local copy is only a cache of the server state, so a
write that doesn't fit now drops it instead of throwing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
larssandandClaude Opus 5.5 committed 2026-10-18 16:06:35 +02:00
1 parent c8a797fe6f
commit 2c6c37f6ca
9 files changed
+99 -4

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
// The browser's localStorage copy of the state is only a cache: the server's SQLite state is the
// truth and every page load hydrates from it. A big installation (results, training ledger, logo)
// outgrows the ~5 MB quota, and setItem then throws - which used to abort whatever called
// saveState(), e.g. connecting the decoder. A cache that can't be written is dropped instead
// (the page then starts from the server like a fresh browser); a cut-down copy is never kept,
// since a partial state could be synced back over the server's.
export function writeLocalCache(storage, key, value) {
try {
storage.setItem(key, JSON.stringify(value));
return { ok: true };
} catch (error) {
try { storage.removeItem(key); } catch {}
return { ok: false, error };
}
}