fix(feed): scope saved filters + default view per account
Feed filters and the default-saved-view mirror lived under shared localStorage keys, so one account's view (incl. its starred default) leaked into another account signed into the same browser — visible with per-tab accounts as a fresh account showing the previous account's 'N active' filters instead of a clean default. Key both by the tab's active account (siftlode.filters.<id> / siftlode.defaultViewFilters.<id>); load a tab's filters from its own account on login/switch/add, falling back to defaults when the account isn't known yet. A share link's filters still win and are persisted to the account. The old shared keys are simply no longer read (a one-time reset to defaults on the first load after this change; migrating them would risk re-leaking across accounts).
This commit is contained in:
parent
f32c3f08dc
commit
59de0ffdfd
3 changed files with 63 additions and 22 deletions
|
|
@ -32,6 +32,15 @@ export const LS = {
|
|||
|
||||
// --- typed read/write helpers (do the JSON + try/catch once) ----------------------------
|
||||
|
||||
/** Suffix a base localStorage key with an account id. Per-account UI state (the feed filters and
|
||||
* the default-view mirror) must NOT be shared across the accounts signed into one browser — a
|
||||
* bare shared key leaks one account's view into another (and, with per-tab accounts, two tabs
|
||||
* would fight over it). Returns null when the account isn't known yet, so callers fall back to
|
||||
* defaults / skip persistence instead of touching another account's data. */
|
||||
export function accountKey(base: string, id: number | null | undefined): string | null {
|
||||
return id != null ? `${base}.${id}` : null;
|
||||
}
|
||||
|
||||
/** Read an object-shaped value merged over `defaults` (so missing/added keys are tolerated),
|
||||
* falling back to `defaults` on missing or corrupt data. */
|
||||
export function readMerged<T extends object>(key: string, defaults: T): T {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue