fix(queue): update remaining count in real-time when tracks advance

This commit is contained in:
vicrodh committed 2026-01-23 11:14:13 -06:00
1 parent 9501a4b909
commit 1f614c5750
1 file changed
+16 -4
+16 -4
View File
@@ -2131,8 +2131,22 @@
$effect(() => { $effect(() => {
if (isQueueOpen) { if (isQueueOpen) {
syncQueueState(); syncQueueState();
// Also fetch history and calculate remaining tracks from backend updateQueueCounts();
getBackendQueueState().then((state) => { }
});
// Update remaining count when track changes while queue is open
$effect(() => {
// Track the currentTrack to trigger on change
const trackId = currentTrack?.id;
if (isQueueOpen && trackId !== undefined) {
updateQueueCounts();
}
});
// Helper function to fetch and update queue counts and history
async function updateQueueCounts() {
const state = await getBackendQueueState();
if (state) { if (state) {
// Calculate remaining tracks: total - current_index - 1 (for current track) // Calculate remaining tracks: total - current_index - 1 (for current track)
if (state.current_index !== null && state.total_tracks > 0) { if (state.current_index !== null && state.total_tracks > 0) {
@@ -2152,9 +2166,7 @@
})); }));
} }
} }
});
} }
});
// Start/stop lyrics active line updates based on playback state and visibility // Start/stop lyrics active line updates based on playback state and visibility
$effect(() => { $effect(() => {