feat(albumcard): add show-favorite flag to hide the heart in non-favoritable contexts

The shared AlbumCard always rendered the favorite heart (overlay button +
"Add to favorites" menu item). Local Library albums are not Qobuz-favoritable
(Tauri's AlbumCardLibraryLite hides favorite/genre), so the upcoming local
grid needs to suppress it.

Add an additive `show-favorite: bool` (default true) on AlbumCard, threaded
through AlbumCollectionView -> AlbumGrid. The fav overlay button uses
`visible:` (not an `if`) so it stays referenceable by `overlay-on` (keeping
the Qobuz hover-no-flicker behavior intact); the menu item is gated with an
`if`. All existing callers (Discover / Favorites / Label) default to true,
so behavior is unchanged.

cc
This commit is contained in:
vicrodh committed 2026-05-28 22:44:04 -06:00
1 parent 1dfc22dd37
commit 6974721b7a
2 files changed
+12 -1

No files matched your search

+5 -1
View File
@@ -61,6 +61,9 @@ component OverlayButton inherits Rectangle {
export component AlbumCard inherits Rectangle {
in property <AlbumCardItem> album;
// Hide the favorite heart + its menu item in non-favoritable contexts
// (e.g. Local Library albums). Mirrors Tauri's AlbumCardLibraryLite.
in property <bool> show-favorite: true;
// Fade out when the card is being removed (favorites un-favorite).
opacity: root.album.removing ? 0.0 : 1.0;
animate opacity { duration: 250ms; }
@@ -159,6 +162,7 @@ export component AlbumCard inherits Rectangle {
VerticalLayout {
alignment: center;
fav-btn := OverlayButton {
visible: root.show-favorite;
icon: root.album.is-favorite
? @image-url("../assets/icons/heart-filled.svg")
: @image-url("../assets/icons/heart.svg");
@@ -263,7 +267,7 @@ export component AlbumCard inherits Rectangle {
root.media-action("album", root.album.id, "queue");
}
}
ContextMenuItem {
if root.show-favorite: ContextMenuItem {
icon: @image-url("../assets/icons/heart.svg");
label: @tr("Add to favorites");
clicked => {
@@ -18,6 +18,7 @@ component AlbumGrid inherits Rectangle {
in property <length> card-width: 220px;
in property <length> card-height: 266px;
in property <length> card-gap: 24px;
in property <bool> show-favorite: true;
callback open-album(string);
callback open-artist(string);
callback media-action(string, string, string);
@@ -36,6 +37,7 @@ component AlbumGrid inherits Rectangle {
width: root.card-width;
height: root.card-height;
album: album;
show-favorite: root.show-favorite;
clicked(id) => {
root.open-album(id);
}
@@ -55,6 +57,9 @@ export component AlbumCollectionView inherits VerticalLayout {
in property <bool> is-grouped: false;
in property <string> view-mode: "grid"; // "grid" | "list"
in property <bool> show-source: false;
// Forwarded to AlbumCard — hide the favorite heart in non-favoritable
// contexts (Local Library albums).
in property <bool> show-favorite: true;
in property <length> card-width: 220px;
in property <length> card-height: 266px;
in property <length> card-gap: 24px;
@@ -103,6 +108,7 @@ export component AlbumCollectionView inherits VerticalLayout {
// Grid view: a card grid for this section.
if root.view-mode != "list": AlbumGrid {
albums: section.albums;
show-favorite: root.show-favorite;
card-width: root.card-width;
card-height: root.card-height;
card-gap: root.card-gap;
@@ -122,6 +128,7 @@ export component AlbumCollectionView inherits VerticalLayout {
// --- Flat grid -----------------------------------------------------
if !root.is-grouped && root.view-mode == "grid" && root.albums.length > 0: AlbumGrid {
albums: root.albums;
show-favorite: root.show-favorite;
card-width: root.card-width;
card-height: root.card-height;
card-gap: root.card-gap;