refactor(channels): adopt shared Tabs + usePersistedTab for the manager tab row (R13 S2b)
Retire the hand-rolled channel-manager view pills for the shared <Tabs> component (given an optional className so it embeds in the justify-between header without the default mb-4), and back view + layout on usePersistedTab instead of manual getAccountRaw/setAccountRaw useState. That subsumes the account-pin re-hydrate (usePersistedTab now re-reads on the pin), so ChannelsProvider's bespoke markManagerDirty/useAccountRehydrate is gone; setView keeps the history-tab logic (_chTab pushState + popstate) layered on the stable raw setter, and useAccountPersistedState's setter is now memoized so that stable action holds. Per the user's call, unify every channel-manager pill on the rounded-lg idiom: the view tabs via <Tabs>, the sync chips and tag chips + the "manage tags" affordance from rounded-full to rounded-lg — no more odd-one-out rounded-full. gate-green: tsc + vitest 120 + eslint-0 + knip + prettier. Self-E2E'd: tab switch, browser Back across tabs (Blocked->Hidden->Subscriptions with localStorage in sync), and a fresh tab restoring view=hidden on the FIRST load; zero console errors.
This commit is contained in:
@@ -159,11 +159,16 @@ export function useAccountPersistedState(
|
||||
): [string, (value: string) => void] {
|
||||
const [value, setValue] = useState<string>(() => getAccountRaw(base) ?? fallback);
|
||||
const markDirty = useAccountRehydrate(() => setValue(getAccountRaw(base) ?? fallback));
|
||||
const set = (next: string) => {
|
||||
markDirty();
|
||||
setValue(next);
|
||||
setAccountRaw(base, next);
|
||||
};
|
||||
// Stable setter (base + markDirty are both stable) so a provider can build a stable action on top
|
||||
// of it — e.g. ChannelsProvider's setView, which must not change identity on every tab switch.
|
||||
const set = useCallback(
|
||||
(next: string) => {
|
||||
markDirty();
|
||||
setValue(next);
|
||||
setAccountRaw(base, next);
|
||||
},
|
||||
[base, markDirty],
|
||||
);
|
||||
return [value, set];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user