From 4df3fa52a4a8572a62d8df1eb892b6ebe586c5cd Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 8 Feb 2026 15:33:59 -0600 Subject: [PATCH] Eradicate all t-as-lambda-param shadowing across codebase Renamed t -> trk (or tab as contextually appropriate) in all lambda/callback parameters across 6 files that import t from i18n. This prevents vite-plugin-svelte CSS extraction failures (PostCSS "Unknown word" errors) caused by t shadowing the i18n store. Files: +page.svelte, PlaylistDetailView, FavoritesView, TrackReplacementModal, Sidebar, SuggestionsPanel --- src/lib/components/Sidebar.svelte | 2 +- .../components/TrackReplacementModal.svelte | 4 +- .../immersive/panels/SuggestionsPanel.svelte | 12 +- src/lib/components/views/FavoritesView.svelte | 60 ++-- .../views/PlaylistDetailView.svelte | 176 ++++++------ src/routes/+page.svelte | 256 +++++++++--------- 6 files changed, 255 insertions(+), 255 deletions(-) diff --git a/src/lib/components/Sidebar.svelte b/src/lib/components/Sidebar.svelte index 011e7ace5..57e6e0d02 100644 --- a/src/lib/components/Sidebar.svelte +++ b/src/lib/components/Sidebar.svelte @@ -722,7 +722,7 @@ try { const prefs = await invoke('get_favorites_preferences'); // Filter out 'playlists' from tab order for sidebar display - favoritesTabOrder = (prefs.tab_order || ['tracks', 'albums', 'artists']).filter(t => t !== 'playlists'); + favoritesTabOrder = (prefs.tab_order || ['tracks', 'albums', 'artists']).filter(tab => tab !== 'playlists'); } catch (err) { console.debug('[Sidebar] Failed to load favorites preferences:', err); } diff --git a/src/lib/components/TrackReplacementModal.svelte b/src/lib/components/TrackReplacementModal.svelte index 9b1665e14..c1954c7f2 100644 --- a/src/lib/components/TrackReplacementModal.svelte +++ b/src/lib/components/TrackReplacementModal.svelte @@ -75,7 +75,7 @@ limit: 20 }); // Filter out non-streamable tracks - results = response.items.filter(t => t.streamable !== false); + results = response.items.filter(trk => trk.streamable !== false); } catch (err) { console.error('Search failed:', err); results = []; @@ -111,7 +111,7 @@ } function handleConfirm() { - const selected = results.find(t => t.id === selectedTrackId); + const selected = results.find(trk => trk.id === selectedTrackId); if (selected) { onSelect(selected); } diff --git a/src/lib/components/immersive/panels/SuggestionsPanel.svelte b/src/lib/components/immersive/panels/SuggestionsPanel.svelte index c630b3fee..9bf526fb7 100644 --- a/src/lib/components/immersive/panels/SuggestionsPanel.svelte +++ b/src/lib/components/immersive/panels/SuggestionsPanel.svelte @@ -113,7 +113,7 @@ // Extract tracks for recommendations let tracks: Track[] = []; if (artist.tracks_appears_on?.items) { - const filtered = artist.tracks_appears_on.items.filter(t => t.id !== trackId); + const filtered = artist.tracks_appears_on.items.filter(trk => trk.id !== trackId); tracks = dedupeByExactTitle(filtered); } @@ -127,13 +127,13 @@ offset: 0 }); if (artistTracks.items) { - const filtered = artistTracks.items.filter(t => t.id !== trackId); + const filtered = artistTracks.items.filter(trk => trk.id !== trackId); const deduped = dedupeByExactTitle(filtered); // Merge with existing, prioritizing new tracks - const existingIds = new Set(tracks.map(t => t.id)); - for (const t of deduped) { - if (!existingIds.has(t.id)) { - tracks.push(t); + const existingIds = new Set(tracks.map(trk => trk.id)); + for (const trk of deduped) { + if (!existingIds.has(trk.id)) { + tracks.push(trk); } } } diff --git a/src/lib/components/views/FavoritesView.svelte b/src/lib/components/views/FavoritesView.svelte index bed83837e..b17c2be5d 100644 --- a/src/lib/components/views/FavoritesView.svelte +++ b/src/lib/components/views/FavoritesView.svelte @@ -695,7 +695,7 @@ if (type === 'tracks') { favoriteTracks = items as FavoriteTrack[]; // Sync to local cache for other views - const trackIds = favoriteTracks.map(t => t.id); + const trackIds = favoriteTracks.map(trk => trk.id); void syncTrackCache(trackIds); } else if (type === 'albums') { favoriteAlbums = items as FavoriteAlbum[]; @@ -1041,32 +1041,32 @@ } function buildFavoritesQueueTracks(tracks: FavoriteTrack[]) { - return tracks.map(t => ({ - id: t.id, - title: t.title, - artist: t.performer?.name || 'Unknown Artist', - album: t.album?.title || 'Favorites', - duration_secs: t.duration, - artwork_url: t.album?.image?.large || t.album?.image?.thumbnail || t.album?.image?.small || '', - hires: t.hires ?? false, - bit_depth: t.maximum_bit_depth ?? null, - sample_rate: t.maximum_sampling_rate ?? null, + return tracks.map(trk => ({ + id: trk.id, + title: trk.title, + artist: trk.performer?.name || 'Unknown Artist', + album: trk.album?.title || 'Favorites', + duration_secs: trk.duration, + artwork_url: trk.album?.image?.large || trk.album?.image?.thumbnail || trk.album?.image?.small || '', + hires: trk.hires ?? false, + bit_depth: trk.maximum_bit_depth ?? null, + sample_rate: trk.maximum_sampling_rate ?? null, is_local: false, - album_id: t.album?.id || null, - artist_id: t.performer?.id ?? null, + album_id: trk.album?.id || null, + artist_id: trk.performer?.id ?? null, })); } // Accessor functions for VirtualizedTrackList (adapts FavoriteTrack to expected interface) - const getFavoriteTrackId = (t: FavoriteTrack) => t.id; - const getFavoriteTrackNumber = (t: FavoriteTrack, idx: number) => t.track_number || idx + 1; - const getFavoriteTrackTitle = (t: FavoriteTrack) => t.title; - const getFavoriteTrackArtist = (t: FavoriteTrack) => t.performer?.name; - const getFavoriteTrackDuration = (t: FavoriteTrack) => t.duration; - const getFavoriteTrackAlbumKey = (t: FavoriteTrack) => t.album?.id; - const getFavoriteTrackAlbum = (t: FavoriteTrack) => t.album?.title; - const getFavoriteArtistId = (t: FavoriteTrack) => t.performer?.id; - const getFavoriteAlbumId = (t: FavoriteTrack) => t.album?.id; + const getFavoriteTrackId = (trk: FavoriteTrack) => trk.id; + const getFavoriteTrackNumber = (trk: FavoriteTrack, idx: number) => trk.track_number || idx + 1; + const getFavoriteTrackTitle = (trk: FavoriteTrack) => trk.title; + const getFavoriteTrackArtist = (trk: FavoriteTrack) => trk.performer?.name; + const getFavoriteTrackDuration = (trk: FavoriteTrack) => trk.duration; + const getFavoriteTrackAlbumKey = (trk: FavoriteTrack) => trk.album?.id; + const getFavoriteTrackAlbum = (trk: FavoriteTrack) => trk.album?.title; + const getFavoriteArtistId = (trk: FavoriteTrack) => trk.performer?.id; + const getFavoriteAlbumId = (trk: FavoriteTrack) => trk.album?.id; // VirtualizedTrackList requires this but we don't have disc info in favorites function buildFavoritesAlbumSections(tracks: FavoriteTrack[]) { @@ -1104,7 +1104,7 @@ } async function handleTrackClick(track: FavoriteTrack, index: number) { - const trackIds = filteredTracks.map(t => t.id); + const trackIds = filteredTracks.map(trk => trk.id); await setFavoritesContext(trackIds, index); try { @@ -1123,7 +1123,7 @@ try { await setFavoritesQueue(0); - await setFavoritesContext(filteredTracks.map(t => t.id), 0); + await setFavoritesContext(filteredTracks.map(trk => trk.id), 0); onTrackPlay(buildDisplayTrack(filteredTracks[0], 0)); } catch (err) { console.error('Failed to set queue:', err); @@ -1138,7 +1138,7 @@ const shuffled = [...filteredTracks].sort(() => Math.random() - 0.5); const queueTracks = buildFavoritesQueueTracks(shuffled); await invoke('set_queue', { tracks: queueTracks, startIndex: 0 }); - await setFavoritesContext(shuffled.map(t => t.id), 0); + await setFavoritesContext(shuffled.map(trk => trk.id), 0); onTrackPlay(buildDisplayTrack(shuffled[0], 0)); } catch (err) { console.error('Failed to shuffle queue:', err); @@ -1573,8 +1573,8 @@ getQualityBadge={getQualityLabel} buildAlbumSections={buildFavoritesAlbumSections} onTrackPlay={handleVirtualizedTrackPlay} - onTrackPlayNext={onTrackPlayNext ? (t) => onTrackPlayNext(buildDisplayTrackFromFavorite(t)) : undefined} - onTrackPlayLater={onTrackPlayLater ? (t) => onTrackPlayLater(buildDisplayTrackFromFavorite(t)) : undefined} + onTrackPlayNext={onTrackPlayNext ? (trk) => onTrackPlayNext(buildDisplayTrackFromFavorite(trk)) : undefined} + onTrackPlayLater={onTrackPlayLater ? (trk) => onTrackPlayLater(buildDisplayTrackFromFavorite(trk)) : undefined} onTrackAddToPlaylist={onTrackAddToPlaylist} getTrackId={getFavoriteTrackId} getTrackNumber={getFavoriteTrackNumber} @@ -1591,14 +1591,14 @@ hideFavorite={false} isFavoriteOverride={true} getOfflineCacheStatus={getTrackOfflineCacheStatus} - onDownload={onTrackDownload ? (t) => onTrackDownload(buildDisplayTrackFromFavorite(t)) : undefined} + onDownload={onTrackDownload ? (trk) => onTrackDownload(buildDisplayTrackFromFavorite(trk)) : undefined} onRemoveDownload={onTrackRemoveDownload} onShareQobuz={onTrackShareQobuz} - onShareSonglink={onTrackShareSonglink ? (t) => onTrackShareSonglink(buildDisplayTrackFromFavorite(t)) : undefined} + onShareSonglink={onTrackShareSonglink ? (trk) => onTrackShareSonglink(buildDisplayTrackFromFavorite(trk)) : undefined} onGoToAlbum={onTrackGoToAlbum} onGoToArtist={onTrackGoToArtist} onShowInfo={onTrackShowInfo} - onReDownload={onTrackReDownload ? (t) => onTrackReDownload(buildDisplayTrackFromFavorite(t)) : undefined} + onReDownload={onTrackReDownload ? (trk) => onTrackReDownload(buildDisplayTrackFromFavorite(trk)) : undefined} /> diff --git a/src/lib/components/views/PlaylistDetailView.svelte b/src/lib/components/views/PlaylistDetailView.svelte index f4504ec5e..0ffe0cb98 100644 --- a/src/lib/components/views/PlaylistDetailView.svelte +++ b/src/lib/components/views/PlaylistDetailView.svelte @@ -370,7 +370,7 @@ } try { - const qobuzTrackIds = tracks.filter(t => !t.isLocal).map(t => t.id); + const qobuzTrackIds = tracks.filter(trk => !trk.isLocal).map(trk => trk.id); if (qobuzTrackIds.length === 0) { tracksWithLocalCopies = new Set(); return; @@ -436,7 +436,7 @@ ...track, playlist_position: pending.trackIds.length + idx // Local tracks come after Qobuz tracks })); - localTracksMap = new Map(localTracks.map(t => [t.id, t])); + localTracksMap = new Map(localTracks.map(trk => [trk.id, trk])); } else { localTracks = []; localTracksMap = new Map(); @@ -445,7 +445,7 @@ // Regular playlist - use existing command const result = await invoke('playlist_get_local_tracks_with_position', { playlistId }); localTracks = result; - localTracksMap = new Map(result.map(t => [t.id, t])); + localTracksMap = new Map(result.map(trk => [trk.id, trk])); } } catch (err) { console.error('Failed to load local tracks:', err); @@ -704,15 +704,15 @@ const trackIds: [number, boolean][] = []; // Add Qobuz tracks first (in original order) - for (const t of allTracks) { - if (!t.isLocal) { - trackIds.push([t.id, false]); + for (const trk of allTracks) { + if (!trk.isLocal) { + trackIds.push([trk.id, false]); } } // Add local tracks (by their position) - for (const t of localTracksInPlaylist) { - trackIds.push([t.id, true]); + for (const trk of localTracksInPlaylist) { + trackIds.push([trk.id, true]); } // Save to backend @@ -880,9 +880,9 @@ if (selectedIndices[0] === 0) return; // Build new order: swap each selected with the one above - const currentOrder = displayTracks.map(t => ({ - id: t.isLocal ? Math.abs(t.id) : t.id, - isLocal: t.isLocal ?? false + const currentOrder = displayTracks.map(trk => ({ + id: trk.isLocal ? Math.abs(trk.id) : trk.id, + isLocal: trk.isLocal ?? false })); // Move from top to bottom to avoid conflicts @@ -923,9 +923,9 @@ if (selectedIndices[0] === displayTracks.length - 1) return; // Build new order: swap each selected with the one below - const currentOrder = displayTracks.map(t => ({ - id: t.isLocal ? Math.abs(t.id) : t.id, - isLocal: t.isLocal ?? false + const currentOrder = displayTracks.map(trk => ({ + id: trk.isLocal ? Math.abs(trk.id) : trk.id, + isLocal: trk.isLocal ?? false })); // Move from bottom to top to avoid conflicts @@ -1037,10 +1037,10 @@ let filtered = result; if (searchQuery.trim()) { const query = searchQuery.toLowerCase(); - filtered = result.filter(t => - t.title.toLowerCase().includes(query) || - (t.artist?.toLowerCase().includes(query)) || - (t.album?.toLowerCase().includes(query)) + filtered = result.filter(trk => + trk.title.toLowerCase().includes(query) || + (trk.artist?.toLowerCase().includes(query)) || + (trk.album?.toLowerCase().includes(query)) ); } @@ -1135,30 +1135,30 @@ function buildQueueTracks(tracks: DisplayTrack[]) { // Filter out blacklisted artists before building queue - const filteredTracks = tracks.filter(t => { - if (t.isLocal) return true; // Local tracks are never blacklisted - if (!t.artistId) return true; // No artist ID, can't check blacklist - return !isArtistBlacklisted(t.artistId); + const filteredTracks = tracks.filter(trk => { + if (trk.isLocal) return true; // Local tracks are never blacklisted + if (!trk.artistId) return true; // No artist ID, can't check blacklist + return !isArtistBlacklisted(trk.artistId); }); - const queueTracks = filteredTracks.map(t => ({ - id: t.isLocal ? Math.abs(t.id) : t.id, - title: t.title, - artist: t.artist || 'Unknown Artist', - album: t.album || playlist?.name || 'Playlist', - duration_secs: t.durationSeconds, - artwork_url: t.albumArt || getPlaylistImage(), - hires: t.hires ?? false, - bit_depth: t.bitDepth ?? null, - sample_rate: t.samplingRate != null ? (t.isLocal ? t.samplingRate * 1000 : t.samplingRate) : null, - is_local: t.isLocal ?? false, - album_id: t.isLocal ? null : (t.albumId || null), - artist_id: t.isLocal ? null : (t.artistId ?? null), + const queueTracks = filteredTracks.map(trk => ({ + id: trk.isLocal ? Math.abs(trk.id) : trk.id, + title: trk.title, + artist: trk.artist || 'Unknown Artist', + album: trk.album || playlist?.name || 'Playlist', + duration_secs: trk.durationSeconds, + artwork_url: trk.albumArt || getPlaylistImage(), + hires: trk.hires ?? false, + bit_depth: trk.bitDepth ?? null, + sample_rate: trk.samplingRate != null ? (trk.isLocal ? trk.samplingRate * 1000 : trk.samplingRate) : null, + is_local: trk.isLocal ?? false, + album_id: trk.isLocal ? null : (trk.albumId || null), + artist_id: trk.isLocal ? null : (trk.artistId ?? null), })); const localIds = filteredTracks - .filter(t => t.isLocal) - .map(t => Math.abs(t.id)); + .filter(trk => trk.isLocal) + .map(trk => Math.abs(trk.id)); return { queueTracks, localIds }; } @@ -1177,9 +1177,9 @@ // Create playlist context before playing if (playlist) { const trackIds = displayTracks - .filter(t => !t.isLocal) // Only Qobuz tracks in context - .map(t => t.id); - + .filter(trk => !trk.isLocal) // Only Qobuz tracks in context + .map(trk => trk.id); + const contextIndex = trackIds.indexOf(track.id); if (contextIndex >= 0 && trackIds.length > 0) { @@ -1288,7 +1288,7 @@ try { // Get the current position of the track being replaced - const currentIndex = displayTracks.findIndex(t => t.id === trackToReplace!.id); + const currentIndex = displayTracks.findIndex(trk => trk.id === trackToReplace!.id); // Remove the old track await invoke('remove_tracks_from_playlist', { @@ -1416,10 +1416,10 @@ if (allTracks.length === 0) return; // Filter out blacklisted tracks - const playableTracks = allTracks.filter(t => { - if (t.isLocal) return true; - if (!t.artistId) return true; - return !isArtistBlacklisted(t.artistId); + const playableTracks = allTracks.filter(trk => { + if (trk.isLocal) return true; + if (!trk.artistId) return true; + return !isArtistBlacklisted(trk.artistId); }); if (playableTracks.length === 0) return; @@ -1427,8 +1427,8 @@ // Set playback context for playlist if (playlist) { const trackIds = playableTracks - .filter(t => !t.isLocal) // Only Qobuz tracks in context - .map(t => t.id); + .filter(trk => !trk.isLocal) // Only Qobuz tracks in context + .map(trk => trk.id); if (trackIds.length > 0) { await setPlaybackContext( @@ -1449,7 +1449,7 @@ // Play first playable track (handle local vs Qobuz) const firstTrack = playableTracks[0]; if (firstTrack.isLocal && onLocalTrackPlay) { - const localTrack = localTracks.find(t => t.id === Math.abs(firstTrack.id)); + const localTrack = localTracks.find(trk => trk.id === Math.abs(firstTrack.id)); if (localTrack) onLocalTrackPlay(localTrack); } else if (onTrackPlay) { onTrackPlay(firstTrack); @@ -1493,37 +1493,37 @@ if (allTracks.length === 0) return; // Filter out blacklisted tracks - const playableTracks = allTracks.filter(t => { - if (t.isLocal) return true; - if (!t.artistId) return true; - return !isArtistBlacklisted(t.artistId); + const playableTracks = allTracks.filter(trk => { + if (trk.isLocal) return true; + if (!trk.artistId) return true; + return !isArtistBlacklisted(trk.artistId); }); if (playableTracks.length === 0) return; // Collect local track IDs to add to set const localIds = playableTracks - .filter(t => t.isLocal) - .map(t => Math.abs(t.id)); + .filter(trk => trk.isLocal) + .map(trk => Math.abs(trk.id)); // Add in reverse order so first track ends up right after current for (let i = playableTracks.length - 1; i >= 0; i--) { - const t = playableTracks[i]; + const trk = playableTracks[i]; try { await invoke('add_to_queue_next', { track: { - id: t.isLocal ? Math.abs(t.id) : t.id, - title: t.title, - artist: t.artist || 'Unknown Artist', - album: t.album || playlist?.name || 'Playlist', - duration_secs: t.durationSeconds, - artwork_url: t.albumArt || getPlaylistImage(), - hires: t.hires ?? false, - bit_depth: t.bitDepth ?? null, - sample_rate: t.samplingRate != null ? (t.isLocal ? t.samplingRate * 1000 : t.samplingRate) : null, - is_local: t.isLocal ?? false, - album_id: t.isLocal ? null : (t.albumId || null), - artist_id: t.isLocal ? null : (t.artistId ?? null), + id: trk.isLocal ? Math.abs(trk.id) : trk.id, + title: trk.title, + artist: trk.artist || 'Unknown Artist', + album: trk.album || playlist?.name || 'Playlist', + duration_secs: trk.durationSeconds, + artwork_url: trk.albumArt || getPlaylistImage(), + hires: trk.hires ?? false, + bit_depth: trk.bitDepth ?? null, + sample_rate: trk.samplingRate != null ? (trk.isLocal ? trk.samplingRate * 1000 : trk.samplingRate) : null, + is_local: trk.isLocal ?? false, + album_id: trk.isLocal ? null : (trk.albumId || null), + artist_id: trk.isLocal ? null : (trk.artistId ?? null), } }); } catch (err) { @@ -1542,33 +1542,33 @@ if (allTracks.length === 0) return; // Filter out blacklisted tracks - const playableTracks = allTracks.filter(t => { - if (t.isLocal) return true; - if (!t.artistId) return true; - return !isArtistBlacklisted(t.artistId); + const playableTracks = allTracks.filter(trk => { + if (trk.isLocal) return true; + if (!trk.artistId) return true; + return !isArtistBlacklisted(trk.artistId); }); if (playableTracks.length === 0) return; - const queueTracks = playableTracks.map(t => ({ - id: t.isLocal ? Math.abs(t.id) : t.id, - title: t.title, - artist: t.artist || 'Unknown Artist', - album: t.album || playlist?.name || 'Playlist', - duration_secs: t.durationSeconds, - artwork_url: t.albumArt || getPlaylistImage(), - hires: t.hires ?? false, - bit_depth: t.bitDepth ?? null, - sample_rate: t.samplingRate != null ? (t.isLocal ? t.samplingRate * 1000 : t.samplingRate) : null, - is_local: t.isLocal ?? false, - album_id: t.isLocal ? null : (t.albumId || null), - artist_id: t.isLocal ? null : (t.artistId ?? null), + const queueTracks = playableTracks.map(trk => ({ + id: trk.isLocal ? Math.abs(trk.id) : trk.id, + title: trk.title, + artist: trk.artist || 'Unknown Artist', + album: trk.album || playlist?.name || 'Playlist', + duration_secs: trk.durationSeconds, + artwork_url: trk.albumArt || getPlaylistImage(), + hires: trk.hires ?? false, + bit_depth: trk.bitDepth ?? null, + sample_rate: trk.samplingRate != null ? (trk.isLocal ? trk.samplingRate * 1000 : trk.samplingRate) : null, + is_local: trk.isLocal ?? false, + album_id: trk.isLocal ? null : (trk.albumId || null), + artist_id: trk.isLocal ? null : (trk.artistId ?? null), })); // Collect local track IDs const localIds = playableTracks - .filter(t => t.isLocal) - .map(t => Math.abs(t.id)); + .filter(trk => trk.isLocal) + .map(trk => Math.abs(trk.id)); try { await invoke('add_tracks_to_queue', { tracks: queueTracks }); @@ -1633,7 +1633,7 @@ {:else}
t.albumArt).filter((a): a is string => !!a)} + artworks={tracks.slice(0, 4).map(trk => trk.albumArt).filter((a): a is string => !!a)} size={200} />
@@ -1920,7 +1920,7 @@ playlistId={playlistId} artists={playlistArtists} excludeTrackIds={excludeTrackIds} - existingTracks={tracks.filter(t => !t.isLocal).map(t => ({ title: t.title, artist: t.artist }))} + existingTracks={tracks.filter(trk => !trk.isLocal).map(trk => ({ title: trk.title, artist: trk.artist }))} onAddTrack={handleAddSuggestedTrack} onGoToAlbum={onTrackGoToAlbum} onGoToArtist={onTrackGoToArtist} diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 1ffe28ac0..df2e08e70 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -907,19 +907,19 @@ if (!album?.tracks?.length) return; const artwork = album.artwork || ''; - const queueTracks: BackendQueueTrack[] = album.tracks.map(t => ({ - id: t.id, - title: t.title, - artist: t.artist || album.artist || 'Unknown Artist', + const queueTracks: BackendQueueTrack[] = album.tracks.map(trk => ({ + id: trk.id, + title: trk.title, + artist: trk.artist || album.artist || 'Unknown Artist', album: album.title || '', - duration_secs: t.durationSeconds, + duration_secs: trk.durationSeconds, artwork_url: artwork || null, - hires: t.hires ?? false, - bit_depth: t.bitDepth ?? null, - sample_rate: t.samplingRate ?? null, + hires: trk.hires ?? false, + bit_depth: trk.bitDepth ?? null, + sample_rate: trk.samplingRate ?? null, is_local: false, album_id: album.id, - artist_id: t.artistId ?? album.artistId + artist_id: trk.artistId ?? album.artistId })); await setQueue(queueTracks, 0, true); @@ -951,20 +951,20 @@ const artwork = album.artwork || ''; for (let i = album.tracks.length - 1; i >= 0; i--) { - const t = album.tracks[i]; + const trk = album.tracks[i]; queueTrackNext({ - id: t.id, - title: t.title, - artist: t.artist || album.artist || 'Unknown Artist', + id: trk.id, + title: trk.title, + artist: trk.artist || album.artist || 'Unknown Artist', album: album.title || '', - duration_secs: t.durationSeconds, + duration_secs: trk.durationSeconds, artwork_url: artwork || null, - hires: t.hires ?? false, - bit_depth: t.bitDepth ?? null, - sample_rate: t.samplingRate ?? null, + hires: trk.hires ?? false, + bit_depth: trk.bitDepth ?? null, + sample_rate: trk.samplingRate ?? null, is_local: false, album_id: album.id, - artist_id: t.artistId ?? album.artistId + artist_id: trk.artistId ?? album.artistId }); } showToast($t('toast.playingTracksNext', { values: { count: album.tracks.length } }), 'success'); @@ -975,19 +975,19 @@ if (!album?.tracks?.length) return; const artwork = album.artwork || ''; - const queueTracks: BackendQueueTrack[] = album.tracks.map(t => ({ - id: t.id, - title: t.title, - artist: t.artist || album.artist || 'Unknown Artist', + const queueTracks: BackendQueueTrack[] = album.tracks.map(trk => ({ + id: trk.id, + title: trk.title, + artist: trk.artist || album.artist || 'Unknown Artist', album: album.title || '', - duration_secs: t.durationSeconds, + duration_secs: trk.durationSeconds, artwork_url: artwork || null, - hires: t.hires ?? false, - bit_depth: t.bitDepth ?? null, - sample_rate: t.samplingRate ?? null, + hires: trk.hires ?? false, + bit_depth: trk.bitDepth ?? null, + sample_rate: trk.samplingRate ?? null, is_local: false, album_id: album.id, - artist_id: t.artistId ?? album.artistId + artist_id: trk.artistId ?? album.artistId })); const success = await addTracksToQueue(queueTracks); @@ -1107,19 +1107,19 @@ } const tracks = playlist.tracks.items; - const queueTracks: BackendQueueTrack[] = tracks.map(t => ({ - id: t.id, - title: t.title, - artist: t.performer?.name || 'Unknown Artist', - album: t.album?.title || '', - duration_secs: t.duration, - artwork_url: t.album?.image?.large || t.album?.image?.thumbnail || t.album?.image?.small || null, - hires: t.hires_streamable ?? false, - bit_depth: t.maximum_bit_depth ?? null, - sample_rate: t.maximum_sampling_rate ?? null, + const queueTracks: BackendQueueTrack[] = tracks.map(trk => ({ + id: trk.id, + title: trk.title, + artist: trk.performer?.name || 'Unknown Artist', + album: trk.album?.title || '', + duration_secs: trk.duration, + artwork_url: trk.album?.image?.large || trk.album?.image?.thumbnail || trk.album?.image?.small || null, + hires: trk.hires_streamable ?? false, + bit_depth: trk.maximum_bit_depth ?? null, + sample_rate: trk.maximum_sampling_rate ?? null, is_local: false, - album_id: t.album?.id, - artist_id: t.performer?.id + album_id: trk.album?.id, + artist_id: trk.performer?.id })); await setQueue(queueTracks, 0); @@ -1157,20 +1157,20 @@ const tracks = playlist.tracks.items; // Add in reverse order so they play in correct sequence for (let i = tracks.length - 1; i >= 0; i--) { - const t = tracks[i]; + const trk = tracks[i]; queueTrackNext({ - id: t.id, - title: t.title, - artist: t.performer?.name || 'Unknown Artist', - album: t.album?.title || '', - duration_secs: t.duration, - artwork_url: t.album?.image?.large || t.album?.image?.thumbnail || t.album?.image?.small || null, - hires: t.hires_streamable ?? false, - bit_depth: t.maximum_bit_depth ?? null, - sample_rate: t.maximum_sampling_rate ?? null, + id: trk.id, + title: trk.title, + artist: trk.performer?.name || 'Unknown Artist', + album: trk.album?.title || '', + duration_secs: trk.duration, + artwork_url: trk.album?.image?.large || trk.album?.image?.thumbnail || trk.album?.image?.small || null, + hires: trk.hires_streamable ?? false, + bit_depth: trk.maximum_bit_depth ?? null, + sample_rate: trk.maximum_sampling_rate ?? null, is_local: false, - album_id: t.album?.id, - artist_id: t.performer?.id + album_id: trk.album?.id, + artist_id: trk.performer?.id }); } showToast($t('toast.playingTracksNext', { values: { count: tracks.length } }), 'success'); @@ -1184,19 +1184,19 @@ } const tracks = playlist.tracks.items; - const queueTracks: BackendQueueTrack[] = tracks.map(t => ({ - id: t.id, - title: t.title, - artist: t.performer?.name || 'Unknown Artist', - album: t.album?.title || '', - duration_secs: t.duration, - artwork_url: t.album?.image?.large || t.album?.image?.thumbnail || t.album?.image?.small || null, - hires: t.hires_streamable ?? false, - bit_depth: t.maximum_bit_depth ?? null, - sample_rate: t.maximum_sampling_rate ?? null, + const queueTracks: BackendQueueTrack[] = tracks.map(trk => ({ + id: trk.id, + title: trk.title, + artist: trk.performer?.name || 'Unknown Artist', + album: trk.album?.title || '', + duration_secs: trk.duration, + artwork_url: trk.album?.image?.large || trk.album?.image?.thumbnail || trk.album?.image?.small || null, + hires: trk.hires_streamable ?? false, + bit_depth: trk.maximum_bit_depth ?? null, + sample_rate: trk.maximum_sampling_rate ?? null, is_local: false, - album_id: t.album?.id, - artist_id: t.performer?.id + album_id: trk.album?.id, + artist_id: trk.performer?.id })); const success = await addTracksToQueue(queueTracks); @@ -1270,8 +1270,8 @@ // ALWAYS create context when playing from an album // The setting only affects menu options visibility, not implicit behavior if (selectedAlbum?.tracks) { - const trackIndex = selectedAlbum.tracks.findIndex(t => t.id === track.id); - const trackIds = selectedAlbum.tracks.map(t => t.id); + const trackIndex = selectedAlbum.tracks.findIndex(trk => trk.id === track.id); + const trackIds = selectedAlbum.tracks.map(trk => trk.id); console.log('[Album] Creating context with', trackIds.length, 'tracks, starting at', trackIndex); await setPlaybackContext( @@ -1299,29 +1299,29 @@ console.log('[Album Queue] Building queue from', selectedAlbum.tracks.length, 'album tracks'); // Filter out blacklisted tracks - const playableTracks = selectedAlbum.tracks.filter(t => { - const artistId = t.artistId ?? selectedAlbum.artistId; + const playableTracks = selectedAlbum.tracks.filter(trk => { + const artistId = trk.artistId ?? selectedAlbum.artistId; return !artistId || !isArtistBlacklisted(artistId); }); - const trackIndex = playableTracks.findIndex(t => t.id === track.id); - const queueTracks: BackendQueueTrack[] = playableTracks.map(t => ({ - id: t.id, - title: t.title, - artist: t.artist || selectedAlbum?.artist || 'Unknown Artist', + const trackIndex = playableTracks.findIndex(trk => trk.id === track.id); + const queueTracks: BackendQueueTrack[] = playableTracks.map(trk => ({ + id: trk.id, + title: trk.title, + artist: trk.artist || selectedAlbum?.artist || 'Unknown Artist', album: selectedAlbum?.title || '', - duration_secs: t.durationSeconds, + duration_secs: trk.durationSeconds, artwork_url: artwork || null, - hires: t.hires ?? false, - bit_depth: t.bitDepth ?? null, - sample_rate: t.samplingRate ?? null, + hires: trk.hires ?? false, + bit_depth: trk.bitDepth ?? null, + sample_rate: trk.samplingRate ?? null, is_local: false, album_id: selectedAlbum?.id, - artist_id: t.artistId ?? selectedAlbum?.artistId + artist_id: trk.artistId ?? selectedAlbum?.artistId })); console.log('[Album Queue] Mapped to', queueTracks.length, 'queue tracks (filtered), startIndex:', trackIndex); - console.log('[Album Queue] Track IDs:', queueTracks.map(t => t.id)); + console.log('[Album Queue] Track IDs:', queueTracks.map(trk => trk.id)); // Set the queue starting at the clicked track await setQueue(queueTracks, trackIndex >= 0 ? trackIndex : 0, true); @@ -1544,7 +1544,7 @@ } const allTracks = [queueState.current_track, ...queueState.upcoming].filter(Boolean) as BackendQueueTrack[]; - const trackIndex = allTracks.findIndex(t => String(t.id) === trackId); + const trackIndex = allTracks.findIndex(trk => String(trk.id) === trackId); if (trackIndex >= 0) { // If it's the current track (index 0), just ensure it's playing @@ -1640,7 +1640,7 @@ // Find the track in history const numericId = parseInt(trackId, 10); - const historyTrack = queueState.history.find(t => t.id === numericId); + const historyTrack = queueState.history.find(trk => trk.id === numericId); if (!historyTrack) { showToast($t('toast.trackNotInHistory'), 'error'); return; @@ -1668,8 +1668,8 @@ async function handlePlayAllAlbum() { if (!selectedAlbum?.tracks?.length) return; // Find first non-blacklisted track - const firstPlayableTrack = selectedAlbum.tracks.find(t => { - const artistId = t.artistId ?? selectedAlbum.artistId; + const firstPlayableTrack = selectedAlbum.tracks.find(trk => { + const artistId = trk.artistId ?? selectedAlbum.artistId; return !artistId || !isArtistBlacklisted(artistId); }); if (!firstPlayableTrack) return; @@ -1681,8 +1681,8 @@ if (!selectedAlbum?.tracks?.length) return; // Filter out blacklisted tracks - const playableTracks = selectedAlbum.tracks.filter(t => { - const artistId = t.artistId ?? selectedAlbum.artistId; + const playableTracks = selectedAlbum.tracks.filter(trk => { + const artistId = trk.artistId ?? selectedAlbum.artistId; return !artistId || !isArtistBlacklisted(artistId); }); @@ -1714,8 +1714,8 @@ if (!selectedAlbum?.tracks?.length) return; // Filter out blacklisted tracks - const playableTracks = selectedAlbum.tracks.filter(t => { - const artistId = t.artistId ?? selectedAlbum.artistId; + const playableTracks = selectedAlbum.tracks.filter(trk => { + const artistId = trk.artistId ?? selectedAlbum.artistId; return !artistId || !isArtistBlacklisted(artistId); }); @@ -1724,20 +1724,20 @@ const artwork = selectedAlbum.artwork || ''; // Add in reverse order so first track ends up right after current for (let i = playableTracks.length - 1; i >= 0; i--) { - const t = playableTracks[i]; + const trk = playableTracks[i]; queueTrackNext({ - id: t.id, - title: t.title, - artist: t.artist || selectedAlbum?.artist || 'Unknown Artist', + id: trk.id, + title: trk.title, + artist: trk.artist || selectedAlbum?.artist || 'Unknown Artist', album: selectedAlbum?.title || '', - duration_secs: t.durationSeconds, + duration_secs: trk.durationSeconds, artwork_url: artwork || null, - hires: t.hires ?? false, - bit_depth: t.bitDepth ?? null, - sample_rate: t.samplingRate ?? null, + hires: trk.hires ?? false, + bit_depth: trk.bitDepth ?? null, + sample_rate: trk.samplingRate ?? null, is_local: false, album_id: selectedAlbum?.id, - artist_id: t.artistId ?? selectedAlbum?.artistId + artist_id: trk.artistId ?? selectedAlbum?.artistId }); } showToast($t('toast.playingTracksNext', { values: { count: playableTracks.length } }), 'success'); @@ -1748,27 +1748,27 @@ if (!selectedAlbum?.tracks?.length) return; // Filter out blacklisted tracks - const playableTracks = selectedAlbum.tracks.filter(t => { - const artistId = t.artistId ?? selectedAlbum.artistId; + const playableTracks = selectedAlbum.tracks.filter(trk => { + const artistId = trk.artistId ?? selectedAlbum.artistId; return !artistId || !isArtistBlacklisted(artistId); }); if (playableTracks.length === 0) return; const artwork = selectedAlbum.artwork || ''; - const queueTracks: BackendQueueTrack[] = playableTracks.map(t => ({ - id: t.id, - title: t.title, - artist: t.artist || selectedAlbum?.artist || 'Unknown Artist', + const queueTracks: BackendQueueTrack[] = playableTracks.map(trk => ({ + id: trk.id, + title: trk.title, + artist: trk.artist || selectedAlbum?.artist || 'Unknown Artist', album: selectedAlbum?.title || '', - duration_secs: t.durationSeconds, + duration_secs: trk.durationSeconds, artwork_url: artwork || null, - hires: t.hires ?? false, - bit_depth: t.bitDepth ?? null, - sample_rate: t.samplingRate ?? null, + hires: trk.hires ?? false, + bit_depth: trk.bitDepth ?? null, + sample_rate: trk.samplingRate ?? null, is_local: false, album_id: selectedAlbum?.id, - artist_id: t.artistId ?? selectedAlbum?.artistId + artist_id: trk.artistId ?? selectedAlbum?.artistId })); const success = await addTracksToQueue(queueTracks); @@ -1786,7 +1786,7 @@ function addAlbumToPlaylist(album: AlbumDetail | null) { if (!album?.tracks?.length) return; - const trackIds = album.tracks.map(t => t.id); + const trackIds = album.tracks.map(trk => trk.id); openAddToPlaylist(trackIds); } @@ -2258,19 +2258,19 @@ console.log('[Session] Restoring previous session...'); // Restore queue - const tracks: BackendQueueTrack[] = session.queue_tracks.map(t => ({ - id: t.id, - title: t.title, - artist: t.artist, - album: t.album, - duration_secs: t.duration_secs, - artwork_url: t.artwork_url, - hires: t.hires ?? false, - bit_depth: t.bit_depth ?? null, - sample_rate: t.sample_rate ?? null, - is_local: t.is_local ?? false, - album_id: t.album_id ?? null, - artist_id: t.artist_id ?? null + const tracks: BackendQueueTrack[] = session.queue_tracks.map(trk => ({ + id: trk.id, + title: trk.title, + artist: trk.artist, + album: trk.album, + duration_secs: trk.duration_secs, + artwork_url: trk.artwork_url, + hires: trk.hires ?? false, + bit_depth: trk.bit_depth ?? null, + sample_rate: trk.sample_rate ?? null, + is_local: trk.is_local ?? false, + album_id: trk.album_id ?? null, + artist_id: trk.artist_id ?? null })); await setQueue(tracks, session.current_index ?? 0, true); @@ -2942,13 +2942,13 @@ } 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 + historyTracks = state.history.map(trk => ({ + id: String(trk.id), + artwork: trk.artwork_url || '', + title: trk.title, + artist: trk.artist, + duration: formatDuration(trk.duration_secs), + trackId: trk.id })); } } @@ -3626,7 +3626,7 @@ onTrackPlay={(trackCredits) => { // Find the corresponding track in the selected album and play it if (selectedAlbum?.tracks) { - const track = selectedAlbum.tracks.find(t => t.id === trackCredits.id); + const track = selectedAlbum.tracks.find(trk => trk.id === trackCredits.id); if (track) { handleAlbumTrackPlay(track); }