Connect playlist count callback for single source of truth

Wire onPlaylistCountUpdate from PlaylistDetailView to Sidebar's
updatePlaylistCounts method in +page.svelte. This ensures the
sidebar displays accurate track counts from the database instead
of calculated values that could drift out of sync.
This commit is contained in:
vicrodh committed 2026-01-16 07:19:34 -06:00
1 parent 7292635210
commit aeb13b9ffc
6 files changed
+146 -3

No files matched your search

@@ -132,6 +132,7 @@
onLocalTrackPlayNext?: (track: LocalLibraryTrack) => void;
onLocalTrackPlayLater?: (track: LocalLibraryTrack) => void;
onSetLocalQueue?: (trackIds: number[]) => void;
onPlaylistCountUpdate?: (playlistId: number, qobuzCount: number, localCount: number) => void;
onPlaylistUpdated?: () => void;
onPlaylistDeleted?: (playlistId: number) => void;
activeTrackId?: number | null;
@@ -158,6 +159,7 @@
onLocalTrackPlayNext,
onLocalTrackPlayLater,
onSetLocalQueue,
onPlaylistCountUpdate,
onPlaylistUpdated,
onPlaylistDeleted,
activeTrackId = null,
@@ -253,6 +255,15 @@
}
});
// Notify parent of actual track counts after loading (single source of truth)
$effect(() => {
if (playlist && !loading) {
const qobuzCount = playlist.tracks_count ?? 0;
const localCount = localTracks.length;
onPlaylistCountUpdate?.(playlistId, qobuzCount, localCount);
}
});
async function loadLocalTracks() {
try {
const result = await invoke<PlaylistLocalTrack[]>('playlist_get_local_tracks_with_position', { playlistId });