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
@@ -7,7 +7,6 @@
|
||||
import TrackRow from '../TrackRow.svelte';
|
||||
import HomeSettingsModal from '../HomeSettingsModal.svelte';
|
||||
import { formatDuration, formatQuality, getQobuzImage } from '$lib/adapters/qobuzAdapters';
|
||||
import { handleAddToFavorites } from '$lib/services/trackActions';
|
||||
import {
|
||||
subscribe as subscribeHomeSettings,
|
||||
getSettings,
|
||||
@@ -587,6 +586,7 @@
|
||||
<div class="track-list">
|
||||
{#each continueTracks as track, index}
|
||||
<TrackRow
|
||||
trackId={track.id}
|
||||
number={index + 1}
|
||||
title={track.title}
|
||||
artist={track.artist}
|
||||
@@ -595,8 +595,7 @@
|
||||
hideDownload={true}
|
||||
onPlay={() => onTrackPlay?.(track)}
|
||||
menuActions={{
|
||||
onPlayNow: () => onTrackPlay?.(track),
|
||||
onAddFavorite: () => handleAddToFavorites(track.id)
|
||||
onPlayNow: () => onTrackPlay?.(track)
|
||||
}}
|
||||
/>
|
||||
{/each}
|
||||
|
||||
Reference in new issue
Block a user