refactor(favorites): centralize track favorites in favoritesStore
- Create favoritesStore.ts for centralized favorites state management - Refactor TrackRow to be self-sufficient with internal favorites handling - TrackRow now subscribes to store and toggles favorites internally - Remove redundant favoriteTrackIds state from AlbumDetailView and PlaylistDetailView - Remove manual onAddFavorite prop drilling from all views - Add trackId prop to TrackRow for store lookup (optional for local tracks) - Add hideFavorite prop for local tracks that don't have Qobuz IDs - Load favorites once on app init in +page.svelte
This commit is contained in:
1 parent
48a010c597
commit
1b90a45212
8 files changed
+229
-67
No files matched your search
@@ -377,12 +377,13 @@
|
||||
{@const displayTrack = buildDisplayTrack(track, index)}
|
||||
{@const downloadInfo = getTrackDownloadStatus?.(track.id) ?? { status: 'none' as const, progress: 0 }}
|
||||
<TrackRow
|
||||
trackId={track.id}
|
||||
number={index + 1}
|
||||
title={track.title}
|
||||
artist={track.performer?.name}
|
||||
duration={formatDuration(track.duration)}
|
||||
quality={track.hires ? 'Hi-Res' : undefined}
|
||||
isFavorite={true}
|
||||
isFavoriteOverride={true}
|
||||
downloadStatus={downloadInfo.status}
|
||||
downloadProgress={downloadInfo.progress}
|
||||
onPlay={() => handleTrackClick(track, index)}
|
||||
@@ -392,7 +393,6 @@
|
||||
onPlayNow: () => handleTrackClick(track, index),
|
||||
onPlayNext: onTrackPlayNext ? () => onTrackPlayNext(displayTrack) : undefined,
|
||||
onPlayLater: onTrackPlayLater ? () => onTrackPlayLater(displayTrack) : undefined,
|
||||
onAddFavorite: onTrackAddFavorite ? () => onTrackAddFavorite(track.id) : undefined,
|
||||
onAddToPlaylist: onTrackAddToPlaylist ? () => onTrackAddToPlaylist(track.id) : undefined,
|
||||
onShareQobuz: onTrackShareQobuz ? () => onTrackShareQobuz(track.id) : undefined,
|
||||
onShareSonglink: onTrackShareSonglink ? () => onTrackShareSonglink(displayTrack) : undefined,
|
||||
|
||||
Reference in new issue
Block a user