diff --git a/frontend/src/lib/components/HubBar.svelte b/frontend/src/lib/components/HubBar.svelte index 8a37c37..22e31a4 100644 --- a/frontend/src/lib/components/HubBar.svelte +++ b/frontend/src/lib/components/HubBar.svelte @@ -3,11 +3,17 @@ // /onthisday, /art, /play). Full horizontal nav on wide screens; a hamburger + drop panel // on phones so the bar stays clean. `active` highlights the current section. // News now lives at /news (the hub is `/`). `newsHref` stays overridable for safety. - import { auth } from '$lib/auth.svelte.js'; + import { onMount } from 'svelte'; + import { auth, refresh as refreshAuth } from '$lib/auth.svelte.js'; import Avatar from './Avatar.svelte'; let { active = '', newsHref = '/news' } = $props(); let open = $state(false); + // auth.user paints immediately from its localStorage cache; revalidate once if no + // page has yet (e.g. the hub is the entry point) so the avatar + signed-in state are + // correct everywhere the bar shows, not just on the feed/account pages. + onMount(() => { if (!auth.ready) refreshAuth(); }); + // Close the menu when we cross into desktop width, so it can't linger open and reappear // if the viewport shrinks back to mobile (the CSS hide alone left `open` stale). $effect(() => {