From 85a2abc46a670fc9ce4c9ff55bc8bd7312df82ff Mon Sep 17 00:00:00 2001 From: Lotus CI Date: Mon, 12 Oct 2026 15:28:41 -0400 Subject: [PATCH] fix(logout): clear the call-volume list and settings-sync stamp (#347) Logout left lotus-per-user-volume (Element Call's per-person volume map: whom the previous user called and turned up/down; same origin on the web) and settings-sync-meta: (a key naming the account) in localStorage. clearPlaintextCaches now removes both; device preferences (`settings`) are kept as before. Verified: after joining/leaving a call and logging out via Settings, both keys are gone (unit test added). Fixes #347 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5 --- src/app/state/plaintextCaches.test.ts | 11 +++++++++++ src/app/state/plaintextCaches.ts | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/app/state/plaintextCaches.test.ts b/src/app/state/plaintextCaches.test.ts index 8d0eaa24c..8e72c6392 100644 --- a/src/app/state/plaintextCaches.test.ts +++ b/src/app/state/plaintextCaches.test.ts @@ -83,3 +83,14 @@ test('clearPlaintextCaches wipes drafts (#41) and the status message (#204) but assert.ok(!removed.includes('cinny_session'), 'session key not this module’s concern'); assert.ok(store.has('cinny_session')); }); + +test('clearPlaintextCaches removes the call-volume list and the settings-sync stamp (#347)', () => { + store.clear(); + store.set('lotus-per-user-volume', '{"@bob:server":0.3}'); + store.set('settings-sync-meta:@me:server', '{"lastSyncedAt":1}'); + store.set('settings', '{}'); + clearPlaintextCaches('@me:server'); + assert.equal(store.has('lotus-per-user-volume'), false); + assert.equal(store.has('settings-sync-meta:@me:server'), false); + assert.equal(store.has('settings'), true, 'device preferences are kept'); +}); diff --git a/src/app/state/plaintextCaches.ts b/src/app/state/plaintextCaches.ts index d707e4127..cf9b510fd 100644 --- a/src/app/state/plaintextCaches.ts +++ b/src/app/state/plaintextCaches.ts @@ -47,6 +47,8 @@ const clearMsgDrafts = (): void => { * - `cinny_recent_gifs_v1` / `cinny_recent_stickers_v1` — media the user sent * - `navToActivePath` — per-space last-visited room paths (needs userId) * - `lotus_outbox_v1` — decrypted content of messages not yet sent ([Gitea #112]) + * - `lotus-per-user-volume`, `settings-sync-meta:` — whom you adjusted in + * calls, and a key naming the account ([Gitea #347]) * - `draft-msg-*` — unsent composer drafts (decrypted message text, unscoped by * user — see [Gitea #41]; previously deliberately preserved across logout * (N98), which let the next account on this device see/send a prior user's @@ -92,6 +94,24 @@ const clearStatusMessage = (): void => { }); }; +/** + * [Gitea #347] Per-person residue that isn't message text but still says whom + * the previous user dealt with: Element Call's per-user volume memory (same + * origin on the web — element-call `lotusVolumeMemory.ts`) and the settings-sync + * stamp, whose key names the account. + */ +export const CALL_VOLUME_KEY = 'lotus-per-user-volume'; +const clearCallVolumesAndSyncMeta = (userId?: string): void => { + const keys = [CALL_VOLUME_KEY, ...(userId ? [`settings-sync-meta:${userId}`] : [])]; + keys.forEach((key) => { + try { + localStorage.removeItem(key); + } catch { + // best-effort + } + }); +}; + export const clearPlaintextCaches = (userId?: string): void => { clearTranslationCache(); clearScheduledMessages(); @@ -103,5 +123,6 @@ export const clearPlaintextCaches = (userId?: string): void => { clearOutbox(); clearCallSession(); clearStatusMessage(); + clearCallVolumesAndSyncMeta(userId); if (userId) clearNavToActivePathStore(userId); };