From 8ac1d8a0e6e6cd52f760c0f3ca8e301cb9a91536 Mon Sep 17 00:00:00 2001 From: Ole-Morten Duesund Date: Mon, 25 May 2026 21:21:39 +0200 Subject: [PATCH] fix(nav): clicking "Vinterliste" / "Min liste" while already there refreshes the list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before: goHome() and goPublicHome() did pushUrl(path) + view=value. When the user was already on /hjem (or /) both calls were no-ops — clicking the wordmark or "Min liste" appeared to do nothing. Add a monotonic reloadKey counter in App.svelte. Both nav handlers bump it. Home.svelte takes reloadKey as a prop and runs load() in a $effect when the value changes relative to what it last saw. Skipping the first run is necessary because onMount() already kicks off the initial load — the effect skips on init by comparing reloadKey to lastSeenReloadKey, which both start equal. load() doesn't touch reloadKey so the effect can't self-fire (the previous $effect bug from the archive/hide toggles is documented inline). Search query, edit-in-progress form, and other local state in Home survive the refresh — only the activity fetch re-runs. --- frontend/src/App.svelte | 13 +++++++++++-- frontend/src/components/Home.svelte | 18 +++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index 324a90b..5dc5584 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -203,13 +203,22 @@ view = 'public-home'; } + // Bumped every time goHome / goPublicHome is invoked. Home.svelte + // watches it via a $effect and re-loads when it changes. This makes + // clicking the wordmark or "Min liste" while ALREADY on /hjem or / + // refresh the list — without it, pushUrl is a no-op (same path) and + // view = 'home' is a no-op (same value), so nothing happened before. + let reloadKey = $state(0); + function goHome() { pushUrl('/hjem'); + reloadKey++; view = 'home'; } function goPublicHome() { pushUrl('/'); + reloadKey++; view = 'public-home'; } @@ -261,7 +270,7 @@ {:else if view === 'permalink'} {:else if view === 'public-home'} - + {:else if view === 'login'} {:else} - + {/if}