fix(qt): album cards get their genre and a localized release date
The card was never the problem: AlbumCard.qml renders genre and the date as hover meta and draws the quality badge, and AlbumCollection passes all three. The DOCUMENT arrived incomplete. `home_qt::map_flat_album` — the mapper behind Discover, the label pages, the award pages and DiscoverBrowse — never wrote `genre` at all (it fell through to `..Default::default()`), so that line was empty on every card it feeds. And it took the first four characters of the release date, so those surfaces showed "2021" where the rest of the app shows "Sep 2, 2021". That inconsistency is the actual finding: five mappers already localize through `qbz_text_utils::dates::release_label` and four sliced the year, and the comment on `map_recent_album` — directly below the worst offender — claims the discover cards localize it "exactly" the way it does. They did not. The album-page and artist-page release cards had the same slice and are converted with it. Two year sites are deliberately left alone: `album_qt.rs:959` and `myqbz_builder_fetch_qt.rs:64` produce an `Option<i32>` used to sort and group, not to display. A localized string there would break the ordering, which is exactly the kind of blanket sweep this is not. cc
This commit is contained in:
3 files changed
+25
-17
No files matched your search
@@ -1033,12 +1033,12 @@ fn map_release_card(release: &qbz_models::PageArtistRelease) -> AlbumCardData {
|
||||
.as_ref()
|
||||
.map(|g| g.name.clone())
|
||||
.unwrap_or_default(),
|
||||
year: release
|
||||
.dates
|
||||
.as_ref()
|
||||
.and_then(|d| d.original.as_deref())
|
||||
.and_then(|s| s.get(..4).map(|y| y.to_string()))
|
||||
.unwrap_or_default(),
|
||||
// Localized "Sep 2, 2021" like every other card in the app — this
|
||||
// slot is display text, not a sort key (the numeric-year sites in
|
||||
// this file and in myqbz_builder_fetch keep their `i32` on purpose).
|
||||
year: qbz_text_utils::dates::release_label(
|
||||
release.dates.as_ref().and_then(|d| d.original.as_deref()),
|
||||
),
|
||||
quality_tier: home_qt::quality_tier_from_depth(bit_depth).to_string(),
|
||||
quality_detail: home_qt::quality_detail_from_parts(bit_depth, sample_rate),
|
||||
art_url: crate::cover_artwork_qt::prefer_album_cover(
|
||||
|
||||
@@ -432,12 +432,12 @@ pub(crate) fn map_release(release: &PageArtistRelease) -> AlbumCardData {
|
||||
.as_ref()
|
||||
.map(|g| g.name.clone())
|
||||
.unwrap_or_default(),
|
||||
year: release
|
||||
.dates
|
||||
.as_ref()
|
||||
.and_then(|d| d.original.as_deref())
|
||||
.and_then(|s| s.get(..4).map(|y| y.to_string()))
|
||||
.unwrap_or_default(),
|
||||
// Localized "Sep 2, 2021" like every other card in the app — this
|
||||
// slot is display text, not a sort key (the numeric-year sites in
|
||||
// this file and in myqbz_builder_fetch keep their `i32` on purpose).
|
||||
year: qbz_text_utils::dates::release_label(
|
||||
release.dates.as_ref().and_then(|d| d.original.as_deref()),
|
||||
),
|
||||
quality_tier: home_qt::quality_tier_from_depth(bit_depth).to_string(),
|
||||
quality_detail: home_qt::quality_detail_from_parts(bit_depth, sample_rate),
|
||||
art_url: crate::cover_artwork_qt::prefer_album_cover(
|
||||
|
||||
@@ -1207,11 +1207,15 @@ pub(crate) fn quality_detail_from_parts(bit_depth: Option<u32>, sample_rate: Opt
|
||||
|
||||
/// Flat-Album card mapping (foryou.rs `map_album`).
|
||||
pub(crate) fn map_flat_album(album: Album) -> HomeCard {
|
||||
let year = album
|
||||
.release_date_original
|
||||
.as_deref()
|
||||
.and_then(|s| s.get(..4).map(|y| y.to_string()))
|
||||
.unwrap_or_default();
|
||||
// "Sep 2, 2021", not "2021". The card's `year` slot is a DISPLAY string
|
||||
// and every other mapper in the port already localizes it through
|
||||
// `release_label` (`map_recent_album` right below says so in as many
|
||||
// words); this one sliced the first four characters, so the four biggest
|
||||
// album surfaces — Discover, the label pages, the award pages and
|
||||
// DiscoverBrowse — showed a bare year while Home showed a date. Same
|
||||
// formatter, so a source that only has "2025" still falls back to the
|
||||
// year on its own.
|
||||
let year = qbz_text_utils::dates::release_label(album.release_date_original.as_deref());
|
||||
let quality_tier = match album.maximum_bit_depth {
|
||||
Some(d) if d >= 24 => "hires",
|
||||
Some(_) => "cd",
|
||||
@@ -1237,6 +1241,10 @@ pub(crate) fn map_flat_album(album: Album) -> HomeCard {
|
||||
artist: album.artist.name,
|
||||
artist_id: album.artist.id.to_string(),
|
||||
year,
|
||||
// Never set here before, so the hover meta's genre line was empty on
|
||||
// every card this mapper feeds — the card renders it, the collection
|
||||
// passes it, the document simply had nothing in it.
|
||||
genre: album.genre.map(|g| g.name).unwrap_or_default(),
|
||||
quality_tier,
|
||||
quality_label,
|
||||
// The list arm's QualityBadgeFull renders the bare exact-quality
|
||||
|
||||
Reference in new issue
Block a user