fix: track detail page liked state race condition (#649)

The liked state wasn't loading on the track detail page because of a
race condition with auth initialization:

1. Page loads, navigation effect runs immediately
2. Effect sets loadedForTrackId = currentId
3. BUT auth.isAuthenticated is still false (async auth not resolved)
4. loadLikedState() is skipped
5. Auth resolves, isAuthenticated becomes true
6. Effect runs again, but loadedForTrackId === currentId, so nothing happens
7. Liked state is never fetched

Fix: Split into two separate effects:
- One for general track data (comments, etc.) - runs immediately
- One for liked state - runs when auth.isAuthenticated becomes true

This ensures the liked heart shows correctly even when auth loads after
the initial page render.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

authored by zzstoatzz.io Claude Opus 4.5 and committed by GitHub 9a9c5123 a2ade221

Changed files
+16 -4
frontend
src
routes
track
+16 -4
frontend/src/routes/track/[id]/+page.svelte
··· 305 306 // track which track we've loaded data for to detect navigation 307 let loadedForTrackId = $state<number | null>(null); 308 309 // reload data when navigating between track pages 310 // watch data.track.id (from server) not track.id (local state) ··· 321 newCommentText = ''; 322 editingCommentId = null; 323 editingCommentText = ''; 324 325 // sync track from server data 326 track = data.track; ··· 328 // mark as loaded for this track 329 loadedForTrackId = currentId; 330 331 - // load fresh data 332 - if (auth.isAuthenticated) { 333 - void loadLikedState(); 334 - } 335 void loadComments(); 336 } 337 }); 338
··· 305 306 // track which track we've loaded data for to detect navigation 307 let loadedForTrackId = $state<number | null>(null); 308 + // track if we've loaded liked state for this track (separate from general load) 309 + let likedStateLoadedForTrackId = $state<number | null>(null); 310 311 // reload data when navigating between track pages 312 // watch data.track.id (from server) not track.id (local state) ··· 323 newCommentText = ''; 324 editingCommentId = null; 325 editingCommentText = ''; 326 + likedStateLoadedForTrackId = null; // reset liked state tracking 327 328 // sync track from server data 329 track = data.track; ··· 331 // mark as loaded for this track 332 loadedForTrackId = currentId; 333 334 + // load comments (doesn't require auth) 335 void loadComments(); 336 + } 337 + }); 338 + 339 + // separate effect to load liked state when auth becomes available 340 + $effect(() => { 341 + const currentId = data.track?.id; 342 + if (!currentId || !browser) return; 343 + 344 + // load liked state when authenticated and haven't loaded for this track yet 345 + if (auth.isAuthenticated && likedStateLoadedForTrackId !== currentId) { 346 + likedStateLoadedForTrackId = currentId; 347 + void loadLikedState(); 348 } 349 }); 350