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:
1 parent
7292635210
commit
aeb13b9ffc
6 files changed
+146
-3
No files matched your search
@@ -287,6 +287,19 @@
|
||||
loadLocalTrackCounts();
|
||||
}
|
||||
|
||||
// Update counts for a specific playlist (single source of truth from detail view)
|
||||
export function updatePlaylistCounts(playlistId: number, qobuzCount: number, localCount: number) {
|
||||
// Update Qobuz count in userPlaylists
|
||||
userPlaylists = userPlaylists.map(p =>
|
||||
p.id === playlistId ? { ...p, tracks_count: qobuzCount } : p
|
||||
);
|
||||
// Update local count
|
||||
localTrackCounts.set(playlistId, localCount);
|
||||
localTrackCounts = new Map(localTrackCounts); // Trigger reactivity
|
||||
// Invalidate tooltip cache for this playlist
|
||||
invalidatePlaylistTooltip(playlistId);
|
||||
}
|
||||
|
||||
// Menu handling functions
|
||||
function closeMenu() {
|
||||
menuOpen = false;
|
||||
|
||||
Reference in new issue
Block a user