Multi-account-in-one-browser (esp. with per-tab accounts) leaked one account's client state into another via shared localStorage keys. Scope every account-specific key by the tab's active account (accountKey/readAccount/writeAccount/useAccountPersistedState helpers), so nothing bleeds across accounts or tabs: - Real leaks: selected playlist, client notification history + settings, onboarding-dismissed. - UI position: feed page, channel-manager filter/view + tables, playlist sort, Settings/Stats/ Users/Config tabs. - Previously DB-adopted caches (theme, hints, performance mode, sidebar layout, nav/filter collapse) — now the cache is per-account too, so there's no flash of the other account's value on login. Kept intentionally global: siftlode.lang (needed pre-login on the Welcome page; the DB pref still scopes it per-account after sign-in) and siftlode.seenVersion (a per-browser 'new version' banner). E2EE private keys (IndexedDB) and the chat-dock key were already per-user.
20 lines
728 B
TypeScript
20 lines
728 B
TypeScript
// App-wide "hints" toggle: when on, Tooltip components reveal short explanatory
|
|
// captions on hover so the UI is somewhat self-documenting for new users. Experienced
|
|
// users can turn it off in Settings. Persisted to localStorage (+ server preferences).
|
|
import { createStore } from "./store";
|
|
import { getAccountRaw, LS, setAccountRaw } from "./storage";
|
|
|
|
function load(): boolean {
|
|
return getAccountRaw(LS.hints) !== "0"; // default ON (also when the account isn't known yet)
|
|
}
|
|
|
|
const store = createStore<boolean>(load());
|
|
|
|
export const hintsEnabled = store.get;
|
|
export const subscribeHints = store.subscribe;
|
|
|
|
export function setHintsEnabled(v: boolean): void {
|
|
store.set(v);
|
|
setAccountRaw(LS.hints, v ? "1" : "0");
|
|
}
|