feat(queue): redesign QueuePanel with tabs, history, and infinite play

- Add Queue/History tabs with new layout
- Implement Now Playing card with spectrum animation
- Add History tab showing recently played tracks from backend
- Add Infinite Play toggle (persisted to localStorage)
- Relocate search to footer (expands left)
- Add Up Next counter (X/Y format)
- Implement 20-track pagination with load more
- Add proper i18n keys for new features
- Add new SVG icons (add-to-list, trash-list)
This commit is contained in:
vicrodh committed 2026-01-23 10:28:16 -06:00
1 parent e624d770b9
commit 84c2261829
6 files changed
+785 -349

No files matched your search

File diff suppressed because it is too large. Load diff
+7 -1
View File
@@ -221,6 +221,11 @@
"queue": "Queue",
"upNext": "Up Next",
"history": "History",
"recentlyPlayed": "Recently Played",
"noHistoryYet": "No tracks played yet",
"infinitePlay": "Infinite Play",
"infinitePlayEnabled": "Infinite play enabled",
"infinitePlayDisabled": "Infinite play disabled",
"lyrics": "Lyrics",
"noLyrics": "No lyrics available",
"fetchingLyrics": "Fetching lyrics...",
@@ -299,7 +304,8 @@
"yes": "Yes",
"no": "No",
"ok": "OK",
"loading": "Loading..."
"loading": "Loading...",
"loadMore": "Load More"
},
"settings": {
"title": "Settings",
+7 -1
View File
@@ -221,6 +221,11 @@
"queue": "Cola",
"upNext": "Siguiente",
"history": "Historial",
"recentlyPlayed": "Reproducido Recientemente",
"noHistoryYet": "Sin pistas reproducidas aún",
"infinitePlay": "Reproducción Infinita",
"infinitePlayEnabled": "Reproducción infinita activada",
"infinitePlayDisabled": "Reproducción infinita desactivada",
"lyrics": "Letras",
"noLyrics": "No hay letras disponibles",
"fetchingLyrics": "Buscando letras...",
@@ -299,7 +304,8 @@
"yes": "Sí",
"no": "No",
"ok": "OK",
"loading": "Cargando..."
"loading": "Cargando...",
"loadMore": "Cargar Más"
},
"settings": {
"title": "Ajustes",
+81 -2
View File
@@ -331,6 +331,8 @@
let repeatMode = $state<RepeatMode>('off');
let queue = $state<QueueTrack[]>([]);
let queueTotalTracks = $state(0);
let historyTracks = $state<QueueTrack[]>([]);
let infinitePlayEnabled = $state(false);
// Toast State (from store subscription)
let toast = $state<ToastData | null>(null);
@@ -1040,6 +1042,54 @@
closeQueue();
}
// Toggle infinite play mode (auto-refill queue with similar tracks)
function handleToggleInfinitePlay() {
infinitePlayEnabled = !infinitePlayEnabled;
// Persist to localStorage
try {
localStorage.setItem('qbz-infinite-play', JSON.stringify(infinitePlayEnabled));
} catch {
// Ignore storage errors
}
showToast(infinitePlayEnabled ? 'Infinite play enabled' : 'Infinite play disabled', 'info');
}
// Play a track from history
async function handlePlayHistoryTrack(trackId: string) {
try {
// Get the full queue state to find the track in history
const queueState = await getBackendQueueState();
if (!queueState) {
showToast('Failed to play track', 'error');
return;
}
// Find the track in history
const numericId = parseInt(trackId, 10);
const historyTrack = queueState.history.find(t => t.id === numericId);
if (!historyTrack) {
showToast('Track not found in history', 'error');
return;
}
// Play the track directly
await handleTrackPlay({
id: historyTrack.id,
title: historyTrack.title,
artist: historyTrack.artist,
album: historyTrack.album,
duration: historyTrack.duration_secs,
artwork: historyTrack.artwork_url || '',
quality: historyTrack.hires ? 'Hi-Res' : 'CD',
bitDepth: historyTrack.bit_depth || 16,
samplingRate: historyTrack.sample_rate || 44100
});
} catch (err) {
console.error('Failed to play history track:', err);
showToast('Failed to play track', 'error');
}
}
// Play all tracks from album (starting from first track)
async function handlePlayAllAlbum() {
if (!selectedAlbum?.tracks?.length) return;
@@ -1827,6 +1877,16 @@
initPlaybackContextStore();
initPlaybackPreferences();
// Load infinite play preference
try {
const stored = localStorage.getItem('qbz-infinite-play');
if (stored !== null) {
infinitePlayEnabled = JSON.parse(stored);
}
} catch {
// Ignore storage errors
}
// Note: loadFavorites() is called in handleLoginSuccess after login is confirmed
// This prevents API calls before authentication is complete
@@ -2066,10 +2126,23 @@
};
});
// Sync queue state when opening queue panel
// Sync queue state when opening queue panel (including history)
$effect(() => {
if (isQueueOpen) {
syncQueueState();
// Also fetch history from backend
getBackendQueueState().then((state) => {
if (state?.history) {
historyTracks = state.history.map(t => ({
id: String(t.id),
artwork: t.artwork_url || '',
title: t.title,
artist: t.artist,
duration: formatDuration(t.duration_secs),
trackId: t.id
}));
}
});
}
});
@@ -2093,7 +2166,8 @@
artwork: currentTrack.artwork,
title: currentTrack.title,
artist: currentTrack.artist,
duration: formatDuration(currentTrack.duration)
duration: formatDuration(currentTrack.duration),
trackId: currentTrack.id // For favorite checking in QueuePanel
} : null);
</script>
@@ -2448,10 +2522,15 @@
onClose={closeQueue}
currentTrack={currentQueueTrack ?? undefined}
upcomingTracks={queue}
{historyTracks}
onPlayTrack={handleQueueTrackPlay}
onPlayHistoryTrack={handlePlayHistoryTrack}
onClearQueue={handleClearQueue}
onSaveAsPlaylist={handleSaveQueueAsPlaylist}
onReorderTrack={handleQueueReorder}
onToggleInfinitePlay={handleToggleInfinitePlay}
{infinitePlayEnabled}
{isPlaying}
/>
<!-- Expanded Player -->