From 3ea2bb937bd5f2b495396d839ae96a9a76d7abf0 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sat, 10 Jan 2026 05:00:57 -0600 Subject: [PATCH] fix: update playlist and local track play to use playerStore handlePlaylistTrackPlay and handleLocalTrackPlay were still using local state variables directly instead of playerStore functions, causing the UI to not react to playback state changes. --- src/routes/+page.svelte | 71 ++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 7d56a0c3b..9dc83f0df 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1075,7 +1075,7 @@ ? `${track.bitDepth}bit/${track.samplingRate}kHz` : 'CD Quality'; - currentTrack = { + const newTrack: PlayingTrack = { id: track.id, title: track.title, artist: track.artist || 'Unknown Artist', @@ -1084,13 +1084,11 @@ duration: track.durationSeconds, quality }; - - duration = track.durationSeconds; - currentTime = 0; + setCurrentTrack(newTrack); try { await invoke('play_track', { trackId: track.id }); - isPlaying = true; + setIsPlaying(true); await invoke('set_media_metadata', { title: track.title, @@ -1117,11 +1115,14 @@ track.id ); + // Check if track is favorite + setIsFavorite(await checkTrackFavorite(track.id)); + await syncQueueState(); } catch (err) { console.error('Failed to play track:', err); showToast(`Playback error: ${err}`, 'error'); - isPlaying = false; + setIsPlaying(false); } } @@ -1149,41 +1150,51 @@ : track.format) : track.format; - currentTrack = { + const newTrack: PlayingTrack = { id: track.id, title: track.title, artist: track.artist, album: track.album, artwork, duration: track.duration_secs, - quality + quality, + isLocal: true }; + setCurrentTrack(newTrack); - duration = track.duration_secs; - currentTime = 0; - isPlaying = true; - showToast(`Playing: ${track.title}`, 'success'); + try { + await invoke('library_play_track', { trackId: track.id }); + setIsPlaying(true); + showToast(`Playing: ${track.title}`, 'success'); - // Update MPRIS metadata - await invoke('set_media_metadata', { - title: track.title, - artist: track.artist, - album: track.album, - durationSecs: track.duration_secs, - coverUrl: artwork || null - }); + // Update MPRIS metadata + await invoke('set_media_metadata', { + title: track.title, + artist: track.artist, + album: track.album, + durationSecs: track.duration_secs, + coverUrl: artwork || null + }); - // Show system notification - showTrackNotification(track.title, track.artist, track.album, artwork || undefined); + // Show system notification + showTrackNotification(track.title, track.artist, track.album, artwork || undefined); - // Update Last.fm - updateLastfmNowPlaying( - track.title, - track.artist, - track.album, - track.duration_secs, - track.id - ); + // Update Last.fm + updateLastfmNowPlaying( + track.title, + track.artist, + track.album, + track.duration_secs, + track.id + ); + + // Local tracks don't have Qobuz favorites + setIsFavorite(false); + } catch (err) { + console.error('Failed to play local track:', err); + showToast(`Playback error: ${err}`, 'error'); + setIsPlaying(false); + } } // Handle setting queue from local library (tracks need different playback command)