From 78cf670939133fc4f656f0f42b21a59431a53842 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 7 Oct 2026 07:24:33 -0700 Subject: Rebuildable caches move from localStorage to IndexedDB (cache-store.js) localStorage is ~5M characters per site whatever the device, and a phone had filled it. Profiles, faceless list, reports, follow packs, profile pages, relay lists, the moderation baseline, community directory, link previews, video sizes/probes and search profiles (~3M on that phone) now live in IndexedDB, which shares the site's disk allowance (GBs). cacheStorage keeps localStorage's string API: reads from memory, coalesced write-behind, flushed on hide. Copies migrate on open and are removed once written. Boot waits for it (max 3s) beside the Ark store; caches read at construction re-merge on ready; an early write can't replace the stored copy. A copy an older build writes to localStorage later moves in on first ask. Wallet wipes reach it; private mode stays on localStorage. Read markers, drafts, follows, note threads and sync outboxes stay in localStorage on purpose (cross-tab consistency, early server-rendered seeding). Also asks navigator.storage.persist(). Co-Authored-By: Claude Opus 5.5 --- src/wallet.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/wallet.js') diff --git a/src/wallet.js b/src/wallet.js index 8b88477..bdcb451 100644 --- a/src/wallet.js +++ b/src/wallet.js @@ -23,6 +23,7 @@ import { concatBytes } from '@scure/btc-signer/utils.js'; import { Api, pool, getBackend, explorerWeb, electrumCandidates } from './api.js'; import { ElectrumApi } from './electrum.js'; +import { cacheStorage } from './cache-store.js'; import { schnorr } from '@noble/curves/secp256k1'; // Resolve a same-origin '/path' WebSocket URL to an absolute ws(s):// URL against @@ -1226,11 +1227,13 @@ export class Wallet { } // Namespaced per-wallet persisted state for features (swaps, ark, ...). featureStateKey(name) { return this._cacheKey() + ':' + name; } + // Rebuildable caches (profiles, reports, …) live in IndexedDB through + // cacheStorage; everything else stays in localStorage. See cache-store.js. loadFeatureState(name, fallback = null) { - try { const v = JSON.parse(localStorage.getItem(this.featureStateKey(name)) || 'null'); return v == null ? fallback : v; } catch { return fallback; } + try { const v = JSON.parse(cacheStorage.getItem(this.featureStateKey(name)) || 'null'); return v == null ? fallback : v; } catch { return fallback; } } saveFeatureState(name, value) { - try { localStorage.setItem(this.featureStateKey(name), JSON.stringify(value)); } catch {} + try { cacheStorage.setItem(this.featureStateKey(name), JSON.stringify(value)); } catch {} } -- cgit v1.2.3