From 49cf2246b8a8dcae75dff30f6684ccd979cd6d00 Mon Sep 17 00:00:00 2001 From: npeter83 Date: Mon, 15 Jun 2026 14:59:24 +0200 Subject: [PATCH] fix(nav): persist the current page across reloads Since filters/page are no longer mirrored to the URL (de-URL refactor), pressing F5 on the Channels/Playlists/Stats page dropped back to the feed because the initial page was read only from the (now-absent) ?page= param. Persist page to localStorage and restore it on load; a share link's ?page= still takes precedence. --- frontend/src/App.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index af987fc..f45520e 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -48,6 +48,17 @@ const DEFAULT_FILTERS: FeedFilters = { }; const FILTERS_KEY = "subfeed.filters"; +const PAGE_KEY = "siftlode.page"; + +// Page is navigation state, not a filter, but it's also kept out of the address bar — so +// persist it to localStorage to survive a reload. A share link's ?page= still wins. +function loadInitialPage(): Page { + const params = new URLSearchParams(window.location.search); + if (params.has("page")) return readPage(); + const stored = localStorage.getItem(PAGE_KEY); + if (stored === "channels" || stored === "stats" || stored === "playlists") return stored; + return "feed"; +} function loadStoredFilters(): FeedFilters { try { @@ -70,7 +81,7 @@ export default function App() { const [filters, setFiltersState] = useState(loadInitialFilters); const [view, setView] = useState<"grid" | "list">("grid"); const [sidebarLayout, setSidebarLayoutState] = useState(loadLayout); - const [page, setPageState] = useState(readPage); + const [page, setPageState] = useState(loadInitialPage); const [settingsOpen, setSettingsOpen] = useState(false); const [wizardOpen, setWizardOpen] = useState(false); const [channelFilter, setChannelFilter] = useState("all"); @@ -90,6 +101,7 @@ export default function App() { function setPage(next: Page) { setPageState(next); + localStorage.setItem(PAGE_KEY, next); } function setSidebarLayout(next: SidebarLayout) {