feat(slint/discover): favoriteAlbums row in For You
Add the missing For You "Favorite Albums" carousel (Tauri's
favoriteAlbums), the user's favorited albums capped at 18 in favorite
order, self-hiding when empty. Reuses the album fav-fetch already done in
albums_branch — no new endpoint.
- state.slint: ForYouState.favorite-albums: DiscoverSection.
- foryou.rs: build_favorite_albums (cap 18, unfiltered) + apply_favorite_albums
(mirrors apply_rediscover); wired into albums_branch right after fav_albums
resolves, painting in the same layer as rediscover/radio.
- artwork.rs: ForYouFavoriteAlbum { index } variant + apply arm.
- ForYouView.slint: mount the Carousel after Your Top Artists, before More
From Your Library, gated on favorite-albums.albums.length > 0.
Titled "Favorite Albums" (not Tauri's literal "More From Your Library")
to avoid the label collision with similarAlbums.
cc
This commit is contained in:
4 files changed
+40
No files matched your search
@@ -129,6 +129,8 @@ pub enum ArtworkTarget {
|
||||
ForYouMoreFromLibrary { index: usize },
|
||||
/// A card in ForYouState.rediscover.albums[index].
|
||||
ForYouRediscover { index: usize },
|
||||
/// A card in ForYouState.favorite-albums.albums[index].
|
||||
ForYouFavoriteAlbum { index: usize },
|
||||
/// The Spotlight artist portrait.
|
||||
ForYouSpotlightArtist,
|
||||
/// A card in ForYouState.spotlight-albums[index].
|
||||
@@ -1022,6 +1024,13 @@ fn apply_artwork(
|
||||
model.set_row_data(index, item);
|
||||
}
|
||||
}
|
||||
ArtworkTarget::ForYouFavoriteAlbum { index } => {
|
||||
let model = window.global::<crate::ForYouState>().get_favorite_albums().albums;
|
||||
if let Some(mut item) = model.row_data(index) {
|
||||
item.artwork = image;
|
||||
model.set_row_data(index, item);
|
||||
}
|
||||
}
|
||||
ArtworkTarget::ForYouSpotlightArtist => {
|
||||
window
|
||||
.global::<crate::ForYouState>()
|
||||
|
||||
@@ -395,6 +395,13 @@ fn build_rediscover(fav_albums: &[Album], recent_ids: &HashSet<String>) -> Vec<A
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Favorite Albums — the user's favorited albums, capped at 18, in favorite
|
||||
/// order (matches Tauri's home-resolved favoriteAlbums sliced 18; unfiltered,
|
||||
/// unlike Rediscover).
|
||||
fn build_favorite_albums(fav_albums: &[Album]) -> Vec<AlbumCard> {
|
||||
fav_albums.iter().take(18).cloned().map(map_album).collect()
|
||||
}
|
||||
|
||||
/// Radio Stations — album-seeded tiles from recent + favorite albums,
|
||||
/// deduped, capped at 12.
|
||||
fn build_radio(
|
||||
@@ -628,6 +635,16 @@ fn apply_rediscover(weak: &slint::Weak<AppWindow>, cache: &ImageCache, cards: Ve
|
||||
crate::artwork::spawn_loads(jobs, weak.clone(), cache.clone());
|
||||
}
|
||||
|
||||
fn apply_favorite_albums(weak: &slint::Weak<AppWindow>, cache: &ImageCache, cards: Vec<AlbumCard>) {
|
||||
let jobs = album_jobs(&cards, |i| ArtworkTarget::ForYouFavoriteAlbum { index: i });
|
||||
let w = weak.clone();
|
||||
let _ = w.upgrade_in_event_loop(move |w| {
|
||||
w.global::<ForYouState>()
|
||||
.set_favorite_albums(section("Favorite Albums", &cards));
|
||||
});
|
||||
crate::artwork::spawn_loads(jobs, weak.clone(), cache.clone());
|
||||
}
|
||||
|
||||
fn apply_more_from_library(
|
||||
weak: &slint::Weak<AppWindow>,
|
||||
cache: &ImageCache,
|
||||
@@ -787,6 +804,7 @@ pub fn spawn_for_you<A>(
|
||||
let recent_ids = recent_ids.clone();
|
||||
Box::pin(async move {
|
||||
let fav_albums = fetch_fav_albums(&runtime).await;
|
||||
apply_favorite_albums(&weak, &cache, build_favorite_albums(&fav_albums));
|
||||
apply_rediscover(&weak, &cache, build_rediscover(&fav_albums, &recent_ids));
|
||||
apply_radio(&weak, &cache, build_radio(&recent_album_list, &fav_albums));
|
||||
|
||||
|
||||
Reference in new issue
Block a user