fix(blacklist): align album-cover artwork jobs with the filtered model
Blocked albums looked like they "stayed" and clicking a card opened the adjacent album: the model dropped the blocked album but the artwork jobs were built from the UNFILTERED data with pre-filter indices, so every cover landed on the shifted card (and the card's data was the next album). - artist: artwork_jobs now skips blocked releases and uses a post-filter album_idx that matches apply_artist's filtered+sorted model; the "Latest release" is dropped at the source so the section hides and queues no stale cover. - favorites albums + home Recently Played: filter at the data source so the model AND the artwork jobs derive from the same filtered list. - albumview E1: append composers from the tracklist to the credit line — album.artists carries only performers, so the composer (e.g. Mozart) was missing; now derived distinct from track.composer with a Composer role. cc
This commit is contained in:
4 files changed
+67
-8
No files matched your search
+27
-2
@@ -158,9 +158,13 @@ fn credit_role(roles: Option<&Vec<String>>) -> String {
|
||||
|
||||
/// Build the header credit line (E1): every credited artist with its role,
|
||||
/// falling back to the single primary interpreter when the album carries no
|
||||
/// `artists[]` array (some V2/discover shapes).
|
||||
/// `artists[]` array (some V2/discover shapes). Composers are appended from the
|
||||
/// tracklist — classical albums list the composer on the tracks (and the
|
||||
/// `composer` Artist), NOT in `album.artists` (which carries only performers),
|
||||
/// so the webplayer's "… • Mozart (compositor)" must be derived from there.
|
||||
fn build_credits(album: &Album) -> Vec<ArtistCreditData> {
|
||||
match album.artists.as_ref().filter(|v| !v.is_empty()) {
|
||||
let mut credits: Vec<ArtistCreditData> = match album.artists.as_ref().filter(|v| !v.is_empty())
|
||||
{
|
||||
Some(list) => list
|
||||
.iter()
|
||||
.map(|a| ArtistCreditData {
|
||||
@@ -174,7 +178,28 @@ fn build_credits(album: &Album) -> Vec<ArtistCreditData> {
|
||||
name: album.artist.name.clone(),
|
||||
role: String::new(),
|
||||
}],
|
||||
};
|
||||
|
||||
// Append distinct composers from the tracklist (not already credited).
|
||||
let mut seen: std::collections::HashSet<String> =
|
||||
credits.iter().map(|c| c.id.clone()).collect();
|
||||
let composer_label = qbz_i18n::t("Composer");
|
||||
if let Some(items) = album.tracks.as_ref().map(|c| &c.items) {
|
||||
for track in items {
|
||||
if let Some(comp) = track.composer.as_ref() {
|
||||
let id = comp.id.to_string();
|
||||
if comp.name.is_empty() || !seen.insert(id.clone()) {
|
||||
continue;
|
||||
}
|
||||
credits.push(ArtistCreditData {
|
||||
id,
|
||||
name: comp.name.clone(),
|
||||
role: composer_label.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
credits
|
||||
}
|
||||
|
||||
fn map_album(album: Album) -> AlbumData {
|
||||
|
||||
@@ -355,7 +355,12 @@ fn map_artist(page: PageArtistResponse) -> ArtistData {
|
||||
.unwrap_or_default();
|
||||
|
||||
// "Novedad más reciente" — the single latest-release highlight.
|
||||
let last_release = page.last_release.map(map_release);
|
||||
// Drop a blocked "Latest release" at the SOURCE so has_last_release is
|
||||
// false (section hidden) and no stale cover job is queued.
|
||||
let last_release = page
|
||||
.last_release
|
||||
.map(map_release)
|
||||
.filter(|c| !crate::artist_blacklist::card_blacklisted(&c.id, &c.artist_id));
|
||||
|
||||
// "Appears On" — tracks where the artist guests (tracks_appears_on).
|
||||
// These are TRACKS, not albums; rendered as a flat track section.
|
||||
@@ -442,7 +447,11 @@ fn truncate_words(text: &str, max: usize) -> String {
|
||||
pub fn artwork_jobs(data: &ArtistData) -> Vec<ArtworkJob> {
|
||||
let mut jobs = Vec::new();
|
||||
if let Some(card) = data.last_release.as_ref() {
|
||||
if !card.artwork_url.is_empty() {
|
||||
// The model drops a blocked last-release (apply_artist), so skip its job
|
||||
// too — otherwise the cover would land on the empty slot.
|
||||
if !card.artwork_url.is_empty()
|
||||
&& !crate::artist_blacklist::card_blacklisted(&card.id, &card.artist_id)
|
||||
{
|
||||
jobs.push(ArtworkJob {
|
||||
target: ArtworkTarget::ArtistLastRelease,
|
||||
url: card.artwork_url.clone(),
|
||||
@@ -450,7 +459,14 @@ pub fn artwork_jobs(data: &ArtistData) -> Vec<ArtworkJob> {
|
||||
}
|
||||
}
|
||||
for (section_idx, section) in data.release_sections.iter().enumerate() {
|
||||
for (album_idx, card) in section.cards.iter().enumerate() {
|
||||
// album_idx must be the POST-FILTER index so it matches the filtered
|
||||
// model apply_artist builds; otherwise a blocked card shifts every
|
||||
// subsequent cover onto the wrong album (and clicks open the wrong one).
|
||||
let mut album_idx = 0;
|
||||
for card in section.cards.iter() {
|
||||
if crate::artist_blacklist::card_blacklisted(&card.id, &card.artist_id) {
|
||||
continue;
|
||||
}
|
||||
if !card.artwork_url.is_empty() {
|
||||
jobs.push(ArtworkJob {
|
||||
target: ArtworkTarget::ArtistRelease {
|
||||
@@ -460,6 +476,7 @@ pub fn artwork_jobs(data: &ArtistData) -> Vec<ArtworkJob> {
|
||||
url: card.artwork_url.clone(),
|
||||
});
|
||||
}
|
||||
album_idx += 1;
|
||||
}
|
||||
}
|
||||
jobs
|
||||
|
||||
@@ -293,8 +293,22 @@ where
|
||||
}
|
||||
FavTab::Albums => {
|
||||
let albums: Vec<Album> = serde_json::from_value(items).unwrap_or_default();
|
||||
// Drop blocked albums at the SOURCE so the model + the artwork jobs
|
||||
// (both derived from `items`) stay index-aligned.
|
||||
let (bl, abl) = if crate::artist_blacklist::is_enabled() {
|
||||
(
|
||||
crate::artist_blacklist::ids_snapshot(),
|
||||
crate::artist_blacklist::album_ids_snapshot(),
|
||||
)
|
||||
} else {
|
||||
Default::default()
|
||||
};
|
||||
FavData::Albums {
|
||||
items: albums.into_iter().map(map_album).collect(),
|
||||
items: albums
|
||||
.into_iter()
|
||||
.filter(|a| !qbz_core::core::album_blacklisted(a, &bl, &abl))
|
||||
.map(map_album)
|
||||
.collect(),
|
||||
total,
|
||||
}
|
||||
}
|
||||
@@ -521,10 +535,10 @@ pub fn apply_favorites(window: &AppWindow, data: FavData) {
|
||||
}
|
||||
FavData::Albums { items, total } => {
|
||||
// Everything in the Albums tab is a favorite -> filled heart.
|
||||
// Drop blocked albums (own id) and blacklisted-artist albums.
|
||||
// (Blocked albums are already dropped at the FavData source so the
|
||||
// model + artwork jobs stay index-aligned.)
|
||||
let cards: Vec<AlbumCardItem> = items
|
||||
.into_iter()
|
||||
.filter(|c| !crate::artist_blacklist::card_blacklisted(&c.id, &c.artist_id))
|
||||
.map(|c| {
|
||||
let mut it = to_item(c);
|
||||
it.is_favorite = true;
|
||||
|
||||
@@ -271,6 +271,9 @@ where
|
||||
.collect();
|
||||
let recent_albums = crate::recently::load_albums()
|
||||
.into_iter()
|
||||
// Drop blocked albums (own id) at the SOURCE so the model + artwork jobs
|
||||
// stay index-aligned. Recently Played is Qobuz album ids.
|
||||
.filter(|album| !crate::artist_blacklist::is_album_blacklisted(&album.id))
|
||||
.map(|album| CardData {
|
||||
id: album.id,
|
||||
title: album.title,
|
||||
|
||||
Reference in new issue
Block a user