fix(discovery): wire favorite button on browse/see-all pages (#468)

The heart overlay on AlbumCardLite always renders and calls onFavorite, but
VirtualizedFavoritesAlbumGrid never forwarded onFavorite/isFavorite, so the
button was dead on every discover see-all page. Thread both through the grid
and wire DiscoverBrowseView to the shared albumFavoritesStore (same pattern as
the collapsed DiscoveryView). Fixes favoriting across all six browse pages.

cc
This commit is contained in:
vicrodh committed 2026-05-22 21:46:34 -06:00
1 parent 50384d3d3c
commit f5de06aeef
2 files changed
+27

No files matched your search

@@ -53,6 +53,8 @@
onLoadMore?: () => void;
isLoadingMore?: boolean;
onAddAlbumToPlaylist?: (albumId: string) => void;
onAlbumFavorite?: (albumId: string) => void;
isAlbumFavorite?: (albumId: string) => boolean;
}
let {
@@ -79,6 +81,8 @@
onLoadMore,
isLoadingMore = false,
onAddAlbumToPlaylist,
onAlbumFavorite,
isAlbumFavorite,
}: Props = $props();
// Constants
@@ -330,6 +334,8 @@
onShareSonglink={onAlbumShareSonglink ? () => onAlbumShareSonglink(album.id) : undefined}
onDownload={onAlbumDownload ? () => onAlbumDownload(album.id) : undefined}
onReDownloadAlbum={onReDownloadAlbum ? () => onReDownloadAlbum(album.id) : undefined}
isFavorite={isAlbumFavorite?.(album.id) ?? false}
onFavorite={onAlbumFavorite ? () => onAlbumFavorite(album.id) : undefined}
onClick={() => handleAlbumClickEvent(album.id)}
/>
</div>
@@ -9,6 +9,11 @@
getSelectedGenreIds,
type GenreFilterContext
} from '$lib/stores/genreFilterStore';
import {
isAlbumFavorite,
toggleAlbumFavorite,
subscribe as subscribeAlbumFavs,
} from '$lib/stores/albumFavoritesStore';
interface DiscoverAlbum {
id: string;
@@ -94,6 +99,20 @@
};
const genreContext = $derived(GENRE_CONTEXT_MAP[endpointType]);
// Album favorite state — reactive against the shared albumFavoritesStore so
// the heart on each card reflects (and toggles) real favorite status. The
// collapsed Discovery view already wires this; the "see all" browse pages
// were missing it, so the heart did nothing here (issue #468).
let favoritesVersion = $state(0);
$effect(() => {
const unsub = subscribeAlbumFavs(() => { favoritesVersion++; });
return unsub;
});
function isFav(albumId: string): boolean {
void favoritesVersion;
return isAlbumFavorite(albumId);
}
// State
let albums = $state<FavoriteAlbum[]>([]);
let hasMore = $state(true);
@@ -309,6 +328,8 @@
onOpenAlbumFolder={onOpenAlbumFolder}
onReDownloadAlbum={onReDownloadAlbum}
onAddAlbumToPlaylist={onAddAlbumToPlaylist}
onAlbumFavorite={(id) => { void toggleAlbumFavorite(id); }}
isAlbumFavorite={isFav}
{downloadStateVersion}
{isAlbumDownloaded}
{showRanking}