From bddb8d22b0df050be8e1af88fe875b1e62228214 Mon Sep 17 00:00:00 2001 From: jay Date: Mon, 29 Jun 2026 05:56:26 -0400 Subject: [PATCH] HubBar: revalidate auth on mount so the avatar shows on cold hub entry auth.user paints from its localStorage cache, but if the hub is the entry point nothing had refreshed the session. Revalidate once (guarded on !auth.ready) so the profile picture + signed-in state are correct wherever the shared bar renders. Co-Authored-By: Claude Opus 4.8 --- frontend/src/lib/components/HubBar.svelte | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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(() => {