feat(slint): stamp is-blacklisted on album/playlist/favorites/suggest rows; protect local+Plex; nav-only menu on blacklisted rows

cc
This commit is contained in:
vicrodh committed 2026-06-17 00:44:47 -06:00
1 parent 95629713b3
commit 6566b507de
13 files changed
+150 -41

No files matched your search

+13
View File
@@ -300,6 +300,9 @@ pub fn apply_album(window: &AppWindow, data: AlbumData) {
// album link target is this album's own id (the album column is not
// shown here, but album-id keeps the row model complete).
let album_id: slint::SharedString = data.id.clone().into();
// Album's primary artist id — the fallback blacklist key for rows whose
// own performer id is missing (Task 6: `track.artist_id ?? album.artist_id`).
let album_artist_id = data.artist_id.clone();
// Multi-disc grouping (Tauri PurchaseAlbumDetailView: groupByDisc +
// isMultiDisc). The album is "multi-disc" when its tracks span more than
// one distinct disc number; only then do we emit "Disc N" headers. The
@@ -334,6 +337,15 @@ pub fn apply_album(window: &AppWindow, data: AlbumData) {
0
};
prev_disc = Some(track.disc);
// Blacklist key: the row's own performer id, falling back to the
// album's primary artist when the track carries none (Task 6).
let row_artist_id = if track.artist_id.is_empty() {
album_artist_id.as_str()
} else {
track.artist_id.as_str()
};
let is_blacklisted =
crate::artist_blacklist::stamp_row("qobuz", &[row_artist_id]);
TrackItem {
id: track.id.clone().into(),
number: track.number.into(),
@@ -350,6 +362,7 @@ pub fn apply_album(window: &AppWindow, data: AlbumData) {
is_favorite: crate::fav_cache::is_favorite(&track.id),
artist_id: track.artist_id.into(),
album_id: album_id.clone(),
is_blacklisted,
removing: false,
cache_status: if crate::offline_cache::is_cached(&track.id) { 3 } else { 0 },
cache_progress: 0.0,
+3
View File
@@ -494,6 +494,9 @@ pub fn apply_artist(window: &AppWindow, data: ArtistData) {
.top_tracks
.into_iter()
.map(|track| TrackItem {
// Out of Task 6 row-stamping scope: ArtistView gets the T9
// hidden-artist banner, not per-row greyout. Never stamped here.
is_blacklisted: false,
id: track.id.clone().into(),
number: track.number.into(),
title: track.title.into(),
+34
View File
@@ -91,6 +91,40 @@ pub fn is_blacklisted_id_str(artist_id: &str) -> bool {
is_blacklisted(id)
}
/// Stamp value for a `TrackItem.is-blacklisted` cell (Task 6). The single
/// rule every in-scope track controller (album / playlist / favorites / the
/// four Q-mixes) reuses so render and the Task 7 queue filters agree on what
/// "blacklisted" means per row:
///
/// - **HARD local/Plex guard** — a non-Qobuz `source` is NEVER blacklisted
/// (Codex guardrail; local copies with a numeric Qobuz id must still stay
/// playable). `qobuz_download` rows render `source == "qobuz"`, so they are
/// treated as Qobuz here — that matches Tauri (VTL keys on `!isLocal`).
/// - Resolve the artist from the candidate string ids in order; the first
/// non-empty, numeric, blacklisted id wins (D-FEAT: performer OR composer;
/// album rows that lack a performer fall back to the album's primary artist).
/// - Missing / zero / non-numeric ids => fail-open (`false`).
///
/// The enabled-flag gate and the no-session fail-open live in
/// [`is_blacklisted`], so this never blocks when the feature is off or no
/// session is bound.
///
/// Live re-stamp contract (Step B): there is no change-notify here (the
/// fav_cache pattern). Every in-scope controller already calls this at LOAD
/// time, so navigating to a view always shows correct state. To refresh the
/// CURRENTLY-loaded lists after a blacklist mutation (Task 9 artist toggle /
/// Task 11 manager), the mutation site re-runs that controller's existing
/// reload / re-push path (which re-invokes `stamp_row` per row) — same as how
/// favorites re-push after a `fav_cache` change. There is intentionally no
/// global listener/observer.
pub fn stamp_row(source: &str, artist_ids: &[&str]) -> bool {
// Local / Plex / ephemeral rows are protected — never blacklisted.
if source != "qobuz" {
return false;
}
artist_ids.iter().any(|id| is_blacklisted_id_str(id))
}
/// True when the blacklist feature is enabled. Default-enabled (`true`) when no
/// session is bound.
pub fn is_enabled() -> bool {
+4
View File
@@ -464,6 +464,10 @@ pub fn apply_favorites(window: &AppWindow, data: FavData) {
let rows: Vec<TrackItem> = items
.into_iter()
.map(|t| TrackItem {
is_blacklisted: crate::artist_blacklist::stamp_row(
"qobuz",
&[t.artist_id.as_str()],
),
id: t.id.clone().into(),
number: "".into(),
title: t.title.into(),
+2
View File
@@ -756,6 +756,8 @@ fn truncate_words(text: &str, max: usize) -> String {
fn top_track_to_item(t: &TopTrack) -> TrackItem {
TrackItem {
// Label landing top-tracks are out of Task 6 row-stamping scope.
is_blacklisted: false,
id: t.id.clone().into(),
number: "".into(),
title: t.title.clone().into(),
+2
View File
@@ -755,6 +755,8 @@ fn map_local_track(t: qbz_library::LocalTrack) -> TrackItem {
let (tier, quality_detail, _) =
crate::quality::badge(&t.format.to_string(), t.bit_depth, Some(t.sample_rate));
TrackItem {
// Local Library rows are local assets — never blacklisted (protected).
is_blacklisted: false,
id: t.id.to_string().into(),
number: t.track_number.map(|n| n.to_string()).unwrap_or_default().into(),
title: t.title.into(),
+9
View File
@@ -860,6 +860,9 @@ fn row_item(item: &RowItem, queue: Option<&QueueTrack>) -> TrackItem {
sample_rate,
artwork_path,
} => TrackItem {
// Offline cached copy — a local asset, never blacklisted (no
// artist id carried; protected by the local guard either way).
is_blacklisted: false,
id: track_id.to_string().into(),
number: "".into(),
title: title.clone().into(),
@@ -895,6 +898,8 @@ fn row_item(item: &RowItem, queue: Option<&QueueTrack>) -> TrackItem {
Some(track.sample_rate),
);
TrackItem {
// Local / Plex / offline rows are protected — never blacklisted.
is_blacklisted: false,
// The queue id (library row id; the Qobuz id for offline
// copies; the synthetic 2^40-namespaced id for Plex rows)
// so visible-order playback resolves this row.
@@ -936,6 +941,8 @@ fn row_item(item: &RowItem, queue: Option<&QueueTrack>) -> TrackItem {
.and_then(|s| s.to_str())
.unwrap_or(path.as_str());
TrackItem {
// Bare local file — never blacklisted.
is_blacklisted: false,
id: format!("file:{path}").into(),
number: "".into(),
title: name.into(),
@@ -967,6 +974,8 @@ fn row_item(item: &RowItem, queue: Option<&QueueTrack>) -> TrackItem {
// qobuz refs get an unparseable id so no drag/pick path can ever
// re-type them as a catalog id.
RowItem::Unresolved { kind, reference } => TrackItem {
// Unresolved/unavailable row — never blacklisted.
is_blacklisted: false,
id: if *kind == "plex" {
format!("plex:{reference}")
} else {
+7
View File
@@ -240,7 +240,14 @@ fn to_item(track: &Track) -> TrackItem {
if let Some(v) = track.version.as_ref().filter(|v| !v.is_empty()) {
title = format!("{title} ({v})");
}
// Blacklist key: the track's performer id (Qobuz mixes; Task 6).
let performer_id = track
.performer
.as_ref()
.map(|p| p.id.to_string())
.unwrap_or_default();
TrackItem {
is_blacklisted: crate::artist_blacklist::stamp_row("qobuz", &[performer_id.as_str()]),
id: track.id.to_string().into(),
number: "".into(),
title: title.into(),
+3
View File
@@ -686,6 +686,9 @@ fn track_to_item(track: &qbz_models::QueueTrack, resolver_index: usize) -> Track
.unwrap_or_else(|| if track.is_local { "local".into() } else { "qobuz".into() });
TrackItem {
// MyQBZ detail is out of Task 6 row-stamping scope (mixed local/Qobuz
// entity; handled by its own epic). Never stamped here.
is_blacklisted: false,
id: track.id.to_string().into(),
number: (resolver_index + 1).to_string().into(),
title: inline_track_title(track).into(),
+8
View File
@@ -493,7 +493,15 @@ pub(crate) fn to_item(track: &Track) -> TrackItem {
if let Some(v) = track.version.as_ref().filter(|v| !v.is_empty()) {
title = format!("{title} ({v})");
}
// Blacklist key: the track's performer id (pure-Qobuz playlist rows;
// local / Plex rows go through local_playlist::row_item, never stamped).
let performer_id = track
.performer
.as_ref()
.map(|p| p.id.to_string())
.unwrap_or_default();
TrackItem {
is_blacklisted: crate::artist_blacklist::stamp_row("qobuz", &[performer_id.as_str()]),
id: track.id.to_string().into(),
number: "".into(),
title: title.into(),
+3
View File
@@ -368,6 +368,9 @@ fn track_item(row: TrackRowData) -> TrackItem {
let is_favorite = crate::fav_cache::is_favorite(&row.id);
let is_cached = crate::offline_cache::is_cached(&row.id);
TrackItem {
// Combined search DROPS blacklisted rows at build time (T4 snapshot
// filter), so a row reaching here is never blacklisted (no greyout).
is_blacklisted: false,
id: row.id.into(),
number: "".into(),
title: row.title.into(),