mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-28 08:22:24 +00:00
Watch history is ~150 separately encrypted chunk events; decrypting each one is a serialized round-trip to the nip-07 extension (the key lives in the extension and cannot be cached locally), so a full re-decrypt cost many seconds on EVERY load. Chunk events are addressable/replaceable: an unchanged chunk keeps its event id while a modified chunk republishes under a new id. Add a persisted cache (watchHistoryDecryptCache.js) keyed by chunk event id. The fetch path checks it before calling the extension and stores successful decryptions, so reloads decrypt only the chunk(s) that actually changed (typically one) and skip the extension for the rest — across sessions. Bounded to 400 entries; cleared on logout alongside the conversation-key cache. The cached plaintext is no more sensitive than the watch-history items already persisted by the manager. Adds watchHistoryDecryptCache.test.mjs (round-trip, persistence/re-hydrate, bounds, clear). Co-Authored-By: Claude Opus 4.8 <[email protected]>