audio streaming app plyr.fm

fix: network artists fetch missed on initial load due to auth race (#975)

auth.isAuthenticated starts false and resolves asynchronously via
/auth/me. The onMount check evaluated it before it was true, so the
fetch was skipped entirely on first page load. Use a $effect to
reactively trigger the fetch when auth resolves.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

authored by zzstoatzz.io

Claude Opus 4.6 and committed by
GitHub
de95e320 372d7fe4

+9 -5
+9 -5
frontend/src/routes/+page.svelte
··· 47 47 let sentinelElement = $state<HTMLDivElement | null>(null); 48 48 49 49 onMount(async () => { 50 - const [topResult] = await Promise.all([ 51 - fetchTopTracks(10), 52 - tracksCache.fetch(), 53 - auth.isAuthenticated ? networkArtistsCache.fetch() : Promise.resolve() 54 - ]); 50 + const [topResult] = await Promise.all([fetchTopTracks(10), tracksCache.fetch()]); 55 51 topTracks = topResult; 56 52 loadingTopTracks = false; 57 53 initialLoad = false; 54 + }); 55 + 56 + // fetch network artists reactively — auth.isAuthenticated is false on 57 + // initial load and flips to true after the async /auth/me call resolves 58 + $effect(() => { 59 + if (auth.isAuthenticated) { 60 + networkArtistsCache.fetch(); 61 + } 58 62 }); 59 63 60 64 // set up IntersectionObserver for infinite scroll