From 408223b4e1e6263346da489a154b2275dec907b8 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sat, 27 Jun 2026 16:53:23 -0600 Subject: [PATCH] fix(follow): reflect artist follow across every card surface mark_artist_followed only updated the Search artist cards, so following from (or affecting) For You / the Recommendations carousels left their Follow chips stale. Flip `following` on all of them (Search results + carousel, For You top-artists + artists-to-follow, reco rec-artists + top-artists) so the chip hides ("auto") or flips to Following ("toggle") wherever the artist appears. cc --- crates/qbz/src/search.rs | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/crates/qbz/src/search.rs b/crates/qbz/src/search.rs index c1b543637..5a0866f78 100644 --- a/crates/qbz/src/search.rs +++ b/crates/qbz/src/search.rs @@ -16,8 +16,8 @@ use slint::{ComponentHandle, Model, ModelRc, VecModel}; use crate::artwork::{ArtworkJob, ArtworkTarget}; use crate::{ AlbumCardItem, AppWindow, CortinillaRow as CortinillaRowItem, - CortinillaSection as CortinillaSectionItem, SearchPlaylistItem, SearchState, SlimItem, - TrackItem, + CortinillaSection as CortinillaSectionItem, ExternalRecoState, ForYouState, SearchPlaylistItem, + SearchState, SlimItem, TrackItem, }; thread_local! { @@ -1440,12 +1440,31 @@ pub fn reset_search(window: &AppWindow) { /// Mark an artist as followed in every `SearchState` list it appears in /// (results list + most-popular hero). Runs on the Slint event loop. pub fn mark_artist_followed(window: &AppWindow, artist_id: &str, following: bool) { + // Flip the Follow chip on EVERY visible artist-card surface, so following + // from any of them updates the others (Search, For You, the Recommendations + // carousels). "auto"-mode chips hide once following; "toggle"-mode flip. let state = window.global::(); - if let Some(vm) = state - .get_artists() - .as_any() - .downcast_ref::>() - { + set_slim_following(&state.get_artists(), artist_id, following); + set_slim_following(&state.get_artists_carousel(), artist_id, following); + if state.get_most_popular_kind() == "artist" { + let mut mp = state.get_most_popular_artist(); + if mp.id == artist_id { + mp.following = following; + state.set_most_popular_artist(mp); + } + } + let foryou = window.global::(); + set_slim_following(&foryou.get_top_artists(), artist_id, following); + set_slim_following(&foryou.get_artists_to_follow(), artist_id, following); + let reco = window.global::(); + set_slim_following(&reco.get_rec_artists_common(), artist_id, following); + set_slim_following(&reco.get_rec_artists_recent(), artist_id, following); + set_slim_following(&reco.get_top_artists(), artist_id, following); +} + +/// Flip `following` on the row matching `artist_id` in a `[SlimItem]` model. +fn set_slim_following(model: &ModelRc, artist_id: &str, following: bool) { + if let Some(vm) = model.as_any().downcast_ref::>() { for i in 0..vm.row_count() { if let Some(mut item) = vm.row_data(i) { if item.id == artist_id { @@ -1455,13 +1474,6 @@ pub fn mark_artist_followed(window: &AppWindow, artist_id: &str, following: bool } } } - if state.get_most_popular_kind() == "artist" { - let mut mp = state.get_most_popular_artist(); - if mp.id == artist_id { - mp.following = following; - state.set_most_popular_artist(mp); - } - } } // ==================== Load-more (pagination) ====================