fix(queue): show actual remaining tracks and ∞ when infinite play active
This commit is contained in:
1 parent
fe3db6397a
commit
e200dfd3eb
2 files changed
+17
-9
No files matched your search
@@ -145,11 +145,9 @@
|
||||
.slice(0, displayCount);
|
||||
});
|
||||
|
||||
// The real remaining count is queueTotalTracks minus current track (if playing)
|
||||
// queueTotalTracks from backend includes all tracks in queue
|
||||
const realRemainingTracks = $derived(currentTrack ? Math.max(0, queueTotalTracks - 1) : queueTotalTracks);
|
||||
// queueTotalTracks now represents the actual remaining tracks from backend
|
||||
const displayedTracks = $derived(Math.min(filteredTracks.length, displayCount));
|
||||
const hasMoreTracks = $derived(!searchQuery && (upcomingTracks.length > displayCount || realRemainingTracks > upcomingTracks.length));
|
||||
const hasMoreTracks = $derived(!searchQuery && (upcomingTracks.length > displayCount || queueTotalTracks > upcomingTracks.length));
|
||||
const canDrag = $derived(!searchQuery.trim());
|
||||
|
||||
function loadMore() {
|
||||
@@ -282,7 +280,7 @@
|
||||
{#if upcomingTracks.length > 0}
|
||||
<div class="section up-next-section">
|
||||
<div class="section-label">
|
||||
{$t('player.upNext').toUpperCase()} ({displayedTracks} {$t('player.ofTotal')} {realRemainingTracks})
|
||||
{$t('player.upNext').toUpperCase()} ({displayedTracks} {$t('player.ofTotal')} {infinitePlayEnabled ? '∞' : queueTotalTracks})
|
||||
</div>
|
||||
<div class="tracks-list">
|
||||
{#each filteredTracks as track, index}
|
||||
|
||||
+14
-4
@@ -331,6 +331,7 @@
|
||||
let repeatMode = $state<RepeatMode>('off');
|
||||
let queue = $state<QueueTrack[]>([]);
|
||||
let queueTotalTracks = $state(0);
|
||||
let queueRemainingTracks = $state(0); // Actual remaining tracks (total - current_index - 1)
|
||||
let historyTracks = $state<QueueTrack[]>([]);
|
||||
let infinitePlayEnabled = $state(false);
|
||||
|
||||
@@ -2126,13 +2127,21 @@
|
||||
};
|
||||
});
|
||||
|
||||
// Sync queue state when opening queue panel (including history)
|
||||
// Sync queue state when opening queue panel (including history and remaining count)
|
||||
$effect(() => {
|
||||
if (isQueueOpen) {
|
||||
syncQueueState();
|
||||
// Also fetch history from backend
|
||||
// Also fetch history and calculate remaining tracks from backend
|
||||
getBackendQueueState().then((state) => {
|
||||
if (state?.history) {
|
||||
if (state) {
|
||||
// Calculate remaining tracks: total - current_index - 1 (for current track)
|
||||
if (state.current_index !== null && state.total_tracks > 0) {
|
||||
queueRemainingTracks = state.total_tracks - state.current_index - 1;
|
||||
} else {
|
||||
queueRemainingTracks = state.total_tracks;
|
||||
}
|
||||
|
||||
if (state.history) {
|
||||
historyTracks = state.history.map(t => ({
|
||||
id: String(t.id),
|
||||
artwork: t.artwork_url || '',
|
||||
@@ -2142,6 +2151,7 @@
|
||||
trackId: t.id
|
||||
}));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -2522,7 +2532,7 @@
|
||||
onClose={closeQueue}
|
||||
currentTrack={currentQueueTrack ?? undefined}
|
||||
upcomingTracks={queue}
|
||||
{queueTotalTracks}
|
||||
queueTotalTracks={queueRemainingTracks}
|
||||
{historyTracks}
|
||||
onPlayTrack={handleQueueTrackPlay}
|
||||
onPlayHistoryTrack={handlePlayHistoryTrack}
|
||||
|
||||
Reference in new issue
Block a user