audio streaming app plyr.fm

fix: parallelize network artists fetch with other homepage data (#973)

The /discover/network call was unnecessarily deferred until after top
tracks and latest tracks resolved. No dependency exists — fire all
three concurrently so the artists section appears sooner.

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

authored by zzstoatzz.io

Claude Opus 4.6 and committed by
GitHub
986b2b44 749d5547

+9 -10
+9 -10
frontend/src/routes/+page.svelte
··· 55 55 let sentinelElement = $state<HTMLDivElement | null>(null); 56 56 57 57 onMount(async () => { 58 - // fetch top tracks and latest tracks concurrently 58 + const networkPromise = auth.isAuthenticated 59 + ? fetch(`${API_URL}/discover/network`, { credentials: 'include' }) 60 + .then((r) => (r.ok ? r.json() : [])) 61 + .then((artists: NetworkArtist[]) => (networkArtists = artists)) 62 + .catch(() => {}) 63 + : Promise.resolve(); 64 + 59 65 const [topResult] = await Promise.all([ 60 66 fetchTopTracks(10), 61 - tracksCache.fetch() 67 + tracksCache.fetch(), 68 + networkPromise 62 69 ]); 63 70 topTracks = topResult; 64 71 loadingTopTracks = false; 65 72 initialLoad = false; 66 - 67 - // fetch network artists in the background (only when authenticated) 68 - if (auth.isAuthenticated) { 69 - fetch(`${API_URL}/discover/network`, { credentials: 'include' }) 70 - .then((r) => (r.ok ? r.json() : [])) 71 - .then((artists) => (networkArtists = artists)) 72 - .catch(() => {}); 73 - } 74 73 }); 75 74 76 75 // set up IntersectionObserver for infinite scroll