From 25e04d30721c13691958776937b1ce3af372876f Mon Sep 17 00:00:00 2001 From: npeter83 Date: Sat, 4 Jul 2026 23:42:13 +0200 Subject: [PATCH] fix(views): keep the applied saved view (or filters) across a reload loadAccountFilters preferred the starred default view's mirror over the stored filters, so a reload always snapped back to the default even after you'd picked another view. Now your last-applied filters (setFilters persists them on every change) win; the default view only seeds a fresh account that has never stored filters. Re-apply the default from the sidebar to return to it. --- frontend/src/App.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 8d0376b..40792fd 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -118,11 +118,23 @@ function loadInitialPage(): Page { // the account isn't known yet (first load, before the tab is pinned), start from defaults; the // post-login effect loads the real ones once the id arrives. function loadAccountFilters(id: number | null): FeedFilters { + // Your last-applied filters win, so a reload keeps whatever view you're on (a saved view you + // picked, or manual tweaks) — setFilters persists them under LS.filters on every change. The + // starred default view only SEEDS a fresh account that has never stored filters: it drives the + // very first load, after which that state persists like any other. (Re-apply the default view + // from the sidebar to return to it.) + const fKey = accountKey(LS.filters, id); + let hasStored = false; + try { + hasStored = !!fKey && localStorage.getItem(fKey) != null; + } catch { + /* localStorage may be unavailable */ + } + if (hasStored && fKey) return readMerged(fKey, DEFAULT_FILTERS); const dvKey = accountKey(LS.defaultViewFilters, id); const def = dvKey ? readJSON(dvKey, null) : null; if (def) return { ...DEFAULT_FILTERS, ...def }; - const fKey = accountKey(LS.filters, id); - return fKey ? readMerged(fKey, DEFAULT_FILTERS) : { ...DEFAULT_FILTERS }; + return { ...DEFAULT_FILTERS }; } // URL wins over localStorage so a pasted link reproduces the exact view.