feat(discover): Most Played Albums View-all page with search + play count

Full-page listing opened from the rail's View all (both tabs now wire show-view-all -> HomeActions.open-most-played-albums). New MostPlayedAlbumsView (mirrors RecentAlbumsView) with a search box; AlbumCardItem gains a plays field shown ONLY here (a gated line in AlbumCard). Rust: navigate_most_played_albums loads all_albums(), caches the ranked rows, renders the grid + fires artwork (MostPlayedAlbumsPage target, Qobuz vs Plex/local split); the search box re-filters the cached rows by title/artist and re-renders (mirrors the Qobuz-playlists filter). NavEntry::MostPlayedAlbums + AppShell mount + ContentView variant. Count label in 8 locales. slintcheck green; qbz-crate Rust pending a full build (30GB wall).

cc
This commit is contained in:
vicrodh committed 2026-07-14 01:21:36 -06:00
1 parent 1a7853d9c6
commit 9e7d574be0
17 files changed
+441 -2

No files matched your search

@@ -4523,3 +4523,7 @@ msgstr "Cache konnte nicht geleert werden"
# Most Played Albums rail title # Most Played Albums rail title
msgid "Most Played Albums" msgid "Most Played Albums"
msgstr "Meistgespielte Alben" msgstr "Meistgespielte Alben"
# Most Played Albums View-all — per-card play count
msgid "{} plays"
msgstr "{} Wiedergaben"
@@ -295,3 +295,7 @@ msgstr "Couldn't clear the cache"
# Most Played Albums rail title # Most Played Albums rail title
msgid "Most Played Albums" msgid "Most Played Albums"
msgstr "Most Played Albums" msgstr "Most Played Albums"
# Most Played Albums View-all — per-card play count
msgid "{} plays"
msgstr "{} plays"
@@ -4553,3 +4553,7 @@ msgstr "No se pudo limpiar el caché"
# Most Played Albums rail title # Most Played Albums rail title
msgid "Most Played Albums" msgid "Most Played Albums"
msgstr "Álbumes más escuchados" msgstr "Álbumes más escuchados"
# Most Played Albums View-all — per-card play count
msgid "{} plays"
msgstr "{} reproducciones"
@@ -4523,3 +4523,7 @@ msgstr "Impossible de vider le cache"
# Most Played Albums rail title # Most Played Albums rail title
msgid "Most Played Albums" msgid "Most Played Albums"
msgstr "Albums les plus écoutés" msgstr "Albums les plus écoutés"
# Most Played Albums View-all — per-card play count
msgid "{} plays"
msgstr "{} lectures"
@@ -4512,3 +4512,7 @@ msgstr "キャッシュを削除できませんでした"
# Most Played Albums rail title # Most Played Albums rail title
msgid "Most Played Albums" msgid "Most Played Albums"
msgstr "最も再生したアルバム" msgstr "最も再生したアルバム"
# Most Played Albums View-all — per-card play count
msgid "{} plays"
msgstr "{} 回再生"
@@ -4535,3 +4535,7 @@ msgstr "Kan de cache niet wissen"
# Most Played Albums rail title # Most Played Albums rail title
msgid "Most Played Albums" msgid "Most Played Albums"
msgstr "Meest afgespeelde albums" msgstr "Meest afgespeelde albums"
# Most Played Albums View-all — per-card play count
msgid "{} plays"
msgstr "{} keer afgespeeld"
@@ -4523,3 +4523,7 @@ msgstr "Não foi possível limpar o cache"
# Most Played Albums rail title # Most Played Albums rail title
msgid "Most Played Albums" msgid "Most Played Albums"
msgstr "Álbuns mais tocados" msgstr "Álbuns mais tocados"
# Most Played Albums View-all — per-card play count
msgid "{} plays"
msgstr "{} reproduções"
@@ -4536,3 +4536,7 @@ msgstr "Не удалось очистить кэш"
# Most Played Albums rail title # Most Played Albums rail title
msgid "Most Played Albums" msgid "Most Played Albums"
msgstr "Самые прослушиваемые альбомы" msgstr "Самые прослушиваемые альбомы"
# Most Played Albums View-all — per-card play count
msgid "{} plays"
msgstr "{} воспроизведений"
@@ -455,6 +455,15 @@ export component AlbumCard inherits Rectangle {
overflow: elide; overflow: elide;
} }
} }
// Play count — shown ONLY in the Most Played Albums View-all
// (plays is 0 everywhere else, so nothing draws here).
if root.album.plays > 0: Text {
text: @tr("{} plays", root.album.plays);
color: Theme.text-muted;
font-size: Typography.legal;
vertical-alignment: center;
overflow: elide;
}
} }
// Icon-only quality badge with an exact-quality hover tooltip. // Icon-only quality badge with an exact-quality hover tooltip.
+5 -1
View File
@@ -17,7 +17,7 @@
import { Theme } from "../foundation/semantic-colors.slint"; import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint"; import { Typography } from "../foundation/typography.slint";
import { ForYouState, RadioStationItem, DiscoverState } from "../state.slint"; import { ForYouState, RadioStationItem, DiscoverState, HomeActions } from "../state.slint";
import { Carousel } from "Carousel.slint"; import { Carousel } from "Carousel.slint";
import { SlimCarousel } from "SlimCarousel.slint"; import { SlimCarousel } from "SlimCarousel.slint";
import { ArtistCarousel } from "ArtistCarousel.slint"; import { ArtistCarousel } from "ArtistCarousel.slint";
@@ -132,6 +132,10 @@ export component ForYouView inherits VerticalLayout {
// mostPlayedAlbums — album carousel ranked by local play count. // mostPlayedAlbums — album carousel ranked by local play count.
if desc.id == "mostPlayedAlbums" && ForYouState.most-played-albums.albums.length > 0: Carousel { if desc.id == "mostPlayedAlbums" && ForYouState.most-played-albums.albums.length > 0: Carousel {
section: ForYouState.most-played-albums; section: ForYouState.most-played-albums;
show-view-all: true;
view-all-clicked => {
HomeActions.open-most-played-albums();
}
album-clicked(id) => { album-clicked(id) => {
root.open-album(id); root.open-album(id);
} }
+4
View File
@@ -487,6 +487,10 @@ export component HomeView inherits Rectangle {
if desc.id == "mostPlayedAlbums" if desc.id == "mostPlayedAlbums"
&& HomeState.most-played-albums.albums.length > 0: Carousel { && HomeState.most-played-albums.albums.length > 0: Carousel {
section: HomeState.most-played-albums; section: HomeState.most-played-albums;
show-view-all: true;
view-all-clicked => {
HomeActions.open-most-played-albums();
}
album-clicked(id) => { album-clicked(id) => {
root.album-clicked(id); root.album-clicked(id);
} }
@@ -0,0 +1,198 @@
// Most Played Albums — the full-page listing opened from the rail's "View
// all". Renders the local play-count store (album_play_history), ranked by
// plays desc, as a flat grid. Each card shows its play count (AlbumCardItem
// carries `plays`, non-zero only here). Structure mirrors RecentAlbumsView
// (fixed header + AlbumCollectionView in a Flickable + the shared
// ListScrollbar); the search box is the one addition.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { MostPlayedAlbumsState, MostPlayedAlbumsActions, NavState, ShellState } from "../state.slint";
import { AlbumCollectionView } from "AlbumCollectionView.slint";
import { LoadingSpinner } from "../primitives/LoadingSpinner.slint";
import { ListScrollbar } from "../primitives/ListScrollbar.slint";
import { NavButtons } from "../shell/NavButtons.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
export component MostPlayedAlbumsView inherits Rectangle {
callback open-album(string);
callback open-artist(string);
callback media-action(string, string, string);
property <length> album-w: 200px;
property <length> album-h: 286px;
property <length> gap: 24px;
background: Theme.surface-main;
VerticalLayout {
spacing: 0px;
// --- Fixed header: NavButtons + title (left), search (right) -------
Rectangle {
height: 56px;
background: Theme.surface-main;
HorizontalLayout {
x: 32px;
y: 25px - self.height / 2;
width: self.preferred-width;
height: self.preferred-height;
spacing: 16px;
VerticalLayout {
alignment: center;
NavButtons { }
}
VerticalLayout {
alignment: center;
Text {
text: @tr("Most Played Albums");
color: Theme.text-primary;
font-size: Typography.section;
font-weight: Typography.bold;
vertical-alignment: center;
}
}
}
// Search box, anchored right (filters the grid by title/artist).
search-box := Rectangle {
x: parent.width - self.width - 32px;
y: 25px - self.height / 2;
width: 240px;
height: 34px;
border-radius: 6px;
border-width: 1px;
border-color: Theme.border-subtle;
background: Theme.surface-elevated;
HorizontalLayout {
padding-left: 10px;
padding-right: 10px;
spacing: 8px;
VerticalLayout {
alignment: center;
QbzIcon {
source: @image-url("../assets/icons/search.svg");
width: 14px;
height: 14px;
tint: Theme.text-muted;
}
}
Rectangle {
horizontal-stretch: 1;
input := TextInput {
width: 100%;
height: 100%;
color: Theme.text-primary;
font-size: Typography.body;
vertical-alignment: center;
single-line: true;
text <=> MostPlayedAlbumsState.search;
// Client filter runs in Rust (re-set model + re-fire
// artwork for the matches, like the playlists filter).
changed text => { MostPlayedAlbumsActions.filter(self.text); }
}
Text {
visible: input.text == "";
text: @tr("Search…");
color: Theme.text-muted;
font-size: Typography.body;
vertical-alignment: center;
}
}
}
}
}
// --- Scrolling grid ----------------------------------------------
flick := Flickable {
vertical-stretch: 1;
viewport-width: self.width;
viewport-height: page.preferred-height;
property <string> sr-armed: NavState.restore-scope;
function sr-restore() {
if (NavState.restore-scope == "most-played-albums" && self.viewport-height > self.height) {
self.viewport-y = NavState.scroll-restore;
NavState.restore-scope = "";
}
}
init => { self.sr-restore(); }
changed sr-armed => { self.sr-restore(); }
changed viewport-height => { self.sr-restore(); }
changed viewport-y => { NavState.report-scroll(self.viewport-y); }
page := VerticalLayout {
width: parent.width;
padding-left: 32px;
padding-right: 32px;
padding-top: 8px;
padding-bottom: 100px;
spacing: 0px;
alignment: start;
if MostPlayedAlbumsState.loading: HorizontalLayout {
alignment: center;
VerticalLayout {
alignment: center;
spacing: 12px;
HorizontalLayout {
alignment: center;
LoadingSpinner { size: 36px; }
}
Text {
text: @tr("Loading…");
color: Theme.text-muted;
font-size: 14px;
horizontal-alignment: center;
}
}
}
if !MostPlayedAlbumsState.loading
&& MostPlayedAlbumsState.albums.length == 0: HorizontalLayout {
alignment: center;
Text {
text: @tr("Albums you play will appear here.");
color: Theme.text-muted;
font-size: 14px;
}
}
if !MostPlayedAlbumsState.loading: AlbumCollectionView {
albums: MostPlayedAlbumsState.albums;
view-mode: "grid";
is-grouped: false;
show-source: false;
card-width: root.album-w;
card-height: root.album-h;
card-gap: root.gap;
windowed: true;
visible-top: -flick.viewport-y;
visible-height: flick.height;
content-offset: 8px;
open-album(id) => { root.open-album(id); }
open-artist(id) => { root.open-artist(id); }
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
}
}
}
ListScrollbar {
x: parent.width - self.width - 4px;
y: 56px;
width: 14px;
height: parent.height - 56px;
viewport-height: flick.viewport-height;
visible-height: flick.height;
viewport-y <=> flick.viewport-y;
auto-hide: true;
hover-active: ShellState.pointer-in-window
&& ShellState.pointer-x >= flick.absolute-position.x
&& ShellState.pointer-x <= flick.absolute-position.x + flick.width
&& ShellState.pointer-y >= flick.absolute-position.y
&& ShellState.pointer-y <= flick.absolute-position.y + flick.height;
}
}
+12
View File
@@ -55,6 +55,7 @@ import { LyricsSidebar } from "LyricsSidebar.slint";
import { HomeView } from "../discover/HomeView.slint"; import { HomeView } from "../discover/HomeView.slint";
import { DiscoverBrowseView } from "../discover/DiscoverBrowseView.slint"; import { DiscoverBrowseView } from "../discover/DiscoverBrowseView.slint";
import { RecentAlbumsView } from "../discover/RecentAlbumsView.slint"; import { RecentAlbumsView } from "../discover/RecentAlbumsView.slint";
import { MostPlayedAlbumsView } from "../discover/MostPlayedAlbumsView.slint";
import { AlbumPageView } from "../album/AlbumPageView.slint"; import { AlbumPageView } from "../album/AlbumPageView.slint";
import { LocalAlbumView } from "../album/LocalAlbumView.slint"; import { LocalAlbumView } from "../album/LocalAlbumView.slint";
import { ArtistPageView } from "../artist/ArtistPageView.slint"; import { ArtistPageView } from "../artist/ArtistPageView.slint";
@@ -327,6 +328,17 @@ export component AppShell inherits Rectangle {
root.media-action(kind, id, action); root.media-action(kind, id, action);
} }
} }
if NavState.view == ContentView.most-played-albums: MostPlayedAlbumsView {
open-album(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.album && !OfflineState.offline: AlbumPageView { if NavState.view == ContentView.album && !OfflineState.offline: AlbumPageView {
open-artist(id) => { open-artist(id) => {
root.open-artist(id); root.open-artist(id);
+21 -1
View File
@@ -34,6 +34,8 @@ export struct AlbumCardItem {
quality-detail: string,// "24-bit / 96 kHz" — bare detail for QualityBadgeFull quality-detail: string,// "24-bit / 96 kHz" — bare detail for QualityBadgeFull
track-count: string, // "12" — TRACKS column track-count: string, // "12" — TRACKS column
plain-year: string, // "1973" — bare year for the list-row YEAR column plain-year: string, // "1973" — bare year for the list-row YEAR column
plays: int, // play count — shown ONLY in the Most Played Albums
// View-all (0 elsewhere, so no count is drawn).
} }
// One entry in an A-Z jump strip (favorites tracks name-group / albums // One entry in an A-Z jump strip (favorites tracks name-group / albums
@@ -211,6 +213,9 @@ export global HomeActions {
// "View all" on the Recently Played Albums rail -> the full-page listing // "View all" on the Recently Played Albums rail -> the full-page listing
// (RecentAlbumsView), fed from the local play-history store. // (RecentAlbumsView), fed from the local play-history store.
callback open-recent-albums(); callback open-recent-albums();
// Opens the full "Most Played Albums" page (MostPlayedAlbumsView), fed
// from the local play-count store.
callback open-most-played-albums();
// Fired by HomeView's init on every (re)mount. Rust re-reads the LOCAL // Fired by HomeView's init on every (re)mount. Rust re-reads the LOCAL
// recently-played store into the two rails IF a play was recorded while // recently-played store into the two rails IF a play was recorded while
// Home was off-screen (dirty-flag gated in Rust — a no-op otherwise, so // Home was off-screen (dirty-flag gated in Rust — a no-op otherwise, so
@@ -233,6 +238,21 @@ export global RecentAlbumsState {
in property <bool> loading: false; in property <bool> loading: false;
} }
// MostPlayedAlbumsView — the full "Most Played Albums" page opened from the
// rail's "View all". Ranked by local play count; each item carries its
// `plays`. `search` filters title/artist client-side (visibility only).
export global MostPlayedAlbumsState {
in property <[AlbumCardItem]> albums: [];
in property <bool> loading: false;
in-out property <string> search: "";
}
export global MostPlayedAlbumsActions {
// Filter the loaded page by title/artist. Rust re-sets `albums` to the
// matches and re-fires their artwork (mirrors the Qobuz-playlists filter).
callback filter(string);
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Discover section configurator (Slice 5) — prefs-driven render loop + modal. // Discover section configurator (Slice 5) — prefs-driven render loop + modal.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -1000,7 +1020,7 @@ export global DragActions {
} }
// Which content view the shell shows. // Which content view the shell shows.
export enum ContentView { home, album, artist, artist-releases, settings, search, musician, label, label-releases, award, award-albums, location, favorites, mix, playlist, discover-browse, recent-albums, playlist-manager, offline-manager, blacklist-manager, local-library, local-album, mixtapes, collections, mixtape-detail, discography-builder, purchases, purchase-album, now-playing } export enum ContentView { home, album, artist, artist-releases, settings, search, musician, label, label-releases, award, award-albums, location, favorites, mix, playlist, discover-browse, recent-albums, most-played-albums, playlist-manager, offline-manager, blacklist-manager, local-library, local-album, mixtapes, collections, mixtape-detail, discography-builder, purchases, purchase-album, now-playing }
// In-app toast (transient notification). Mirrors Tauri's toastStore: // In-app toast (transient notification). Mirrors Tauri's toastStore:
// a single toast at a time (a new one replaces the current), auto-hidden // a single toast at a time (a new one replaces the current), auto-hidden
+11
View File
@@ -70,6 +70,9 @@ pub enum ArtworkTarget {
/// model has its own lifecycle, separate from the rail's (same split as /// model has its own lifecycle, separate from the rail's (same split as
/// HomeFavoriteAlbum vs ForYouFavoriteAlbum). /// HomeFavoriteAlbum vs ForYouFavoriteAlbum).
RecentAlbumsPage { idx: usize }, RecentAlbumsPage { idx: usize },
/// A card in `MostPlayedAlbumsState.albums[idx]` — the "Most Played Albums"
/// View-all page.
MostPlayedAlbumsPage { idx: usize },
/// A card in `HomeState.favorite-albums.albums[idx]` — the Home tab's /// A card in `HomeState.favorite-albums.albums[idx]` — the Home tab's
/// "Library Albums" rail (#566). Separate from `ForYouFavoriteAlbum`: /// "Library Albums" rail (#566). Separate from `ForYouFavoriteAlbum`:
/// the two rails share the data pipeline but not the model lifecycle. /// the two rails share the data pipeline but not the model lifecycle.
@@ -938,6 +941,14 @@ fn apply_artwork(
item.artwork = image; item.artwork = image;
albums.set_row_data(idx, item); albums.set_row_data(idx, item);
} }
ArtworkTarget::MostPlayedAlbumsPage { idx } => {
let albums = window.global::<crate::MostPlayedAlbumsState>().get_albums();
let Some(mut item) = albums.row_data(idx) else {
return;
};
item.artwork = image;
albums.set_row_data(idx, item);
}
ArtworkTarget::RecentAlbumsPage { idx } => { ArtworkTarget::RecentAlbumsPage { idx } => {
let albums = window.global::<crate::RecentAlbumsState>().get_albums(); let albums = window.global::<crate::RecentAlbumsState>().get_albums();
let Some(mut item) = albums.row_data(idx) else { let Some(mut item) = albums.row_data(idx) else {
+146
View File
@@ -2345,6 +2345,7 @@ fn scope_for(entry: &nav::NavEntry) -> String {
nav::NavEntry::LocalLibrary { tab } => format!("ll:{tab}"), nav::NavEntry::LocalLibrary { tab } => format!("ll:{tab}"),
nav::NavEntry::DiscoverBrowse { .. } => "discover-browse".into(), nav::NavEntry::DiscoverBrowse { .. } => "discover-browse".into(),
nav::NavEntry::RecentAlbums => "recent-albums".into(), nav::NavEntry::RecentAlbums => "recent-albums".into(),
nav::NavEntry::MostPlayedAlbums => "most-played-albums".into(),
nav::NavEntry::Mix { .. } => "mix".into(), nav::NavEntry::Mix { .. } => "mix".into(),
nav::NavEntry::Playlist(_) => "playlist".into(), nav::NavEntry::Playlist(_) => "playlist".into(),
nav::NavEntry::PlaylistManager => "playlist-manager".into(), nav::NavEntry::PlaylistManager => "playlist-manager".into(),
@@ -2529,6 +2530,9 @@ fn apply_entry(
nav::NavEntry::RecentAlbums => { nav::NavEntry::RecentAlbums => {
navigate_recent_albums(weak.clone(), handle, image_cache.clone()); navigate_recent_albums(weak.clone(), handle, image_cache.clone());
} }
nav::NavEntry::MostPlayedAlbums => {
navigate_most_played_albums(weak.clone(), handle, image_cache.clone());
}
nav::NavEntry::Mix { kind } => { nav::NavEntry::Mix { kind } => {
navigate_mix(runtime.clone(), weak.clone(), handle, image_cache.clone(), kind); navigate_mix(runtime.clone(), weak.clone(), handle, image_cache.clone(), kind);
} }
@@ -2945,6 +2949,125 @@ fn navigate_recent_albums(
}); });
} }
/// Full ranked list for the Most Played Albums View-all, cached so the search
/// box re-filters without re-querying SQLite (mirrors the Qobuz-playlists
/// filter). Written by the navigation, read by the filter.
static MOST_PLAYED_ROWS: std::sync::Mutex<
Vec<qbz_app::settings::album_play_history::AlbumPlayRow>,
> = std::sync::Mutex::new(Vec::new());
/// Map a ranked row to a grid card, carrying its play count (drawn only here;
/// `plays` is 0 on every other AlbumCardItem).
fn most_played_item(row: &qbz_app::settings::album_play_history::AlbumPlayRow) -> AlbumCardItem {
let mut item = home::card_to_item(crate::home::CardData {
id: row.album_id.clone(),
title: row.title.clone(),
artist: row.artist.clone(),
artist_id: row.artist_id.clone(),
year: row.year.clone(),
quality_tier: row.quality_tier.clone(),
quality_label: row.quality_label.clone(),
artwork_url: row.artwork_url.clone(),
source: row.source.clone(),
..Default::default()
});
item.plays = row.plays as i32;
item
}
/// Push ranked rows onto the Most Played Albums page + fire their artwork
/// (Qobuz plain loader vs Plex/local source-aware funnel, like the recent
/// page). Shared by the initial load and the search filter.
fn apply_most_played_page(
weak: &slint::Weak<AppWindow>,
image_cache: artwork::ImageCache,
rows: Vec<qbz_app::settings::album_play_history::AlbumPlayRow>,
) {
let mut jobs: Vec<artwork::ArtworkJob> = Vec::new();
let mut plex_jobs: Vec<artwork::ArtworkJob> = Vec::new();
for (idx, row) in rows.iter().enumerate() {
if row.artwork_url.is_empty() {
continue;
}
let job = artwork::ArtworkJob {
target: artwork::ArtworkTarget::MostPlayedAlbumsPage { idx },
url: row.artwork_url.clone(),
};
if row.source == "plex" || row.source == "local" {
plex_jobs.push(job);
} else {
jobs.push(job);
}
}
let weak_for_plex = weak.clone();
let image_cache_plex = image_cache.clone();
let _ = weak.clone().upgrade_in_event_loop(move |w| {
let items: Vec<AlbumCardItem> = rows.iter().map(most_played_item).collect();
let s = w.global::<MostPlayedAlbumsState>();
s.set_albums(slint::ModelRc::new(slint::VecModel::from(items)));
s.set_loading(false);
});
artwork::spawn_loads(jobs, weak.clone(), image_cache);
if !plex_jobs.is_empty() {
let plex = crate::plex_settings::get();
artwork::spawn_local_or_plex_loads(
plex_jobs,
plex.base_url,
plex.token,
weak_for_plex,
image_cache_plex,
);
}
}
/// Open the full "Most Played Albums" page: load the ranked list, cache it,
/// render it. Local SQLite read, so no runtime + no error branch.
fn navigate_most_played_albums(
weak: slint::Weak<AppWindow>,
handle: &tokio::runtime::Handle,
image_cache: artwork::ImageCache,
) {
handle.spawn(async move {
let _ = weak.upgrade_in_event_loop(|w| {
let s = w.global::<MostPlayedAlbumsState>();
s.set_loading(true);
s.set_search("".into());
s.set_albums(slint::ModelRc::new(slint::VecModel::from(
Vec::<AlbumCardItem>::new(),
)));
w.global::<NavState>()
.set_view(ContentView::MostPlayedAlbums);
});
let rows = qbz_app::settings::album_play_history::all_albums();
*MOST_PLAYED_ROWS.lock().unwrap() = rows.clone();
apply_most_played_page(&weak, image_cache, rows);
});
}
/// Re-filter the cached Most Played list by title/artist and re-render.
fn filter_most_played(
weak: slint::Weak<AppWindow>,
image_cache: artwork::ImageCache,
query: String,
) {
let q = query.trim().to_lowercase();
let rows: Vec<_> = MOST_PLAYED_ROWS
.lock()
.map(|guard| {
guard
.iter()
.filter(|r| {
q.is_empty()
|| r.title.to_lowercase().contains(&q)
|| r.artist.to_lowercase().contains(&q)
})
.cloned()
.collect()
})
.unwrap_or_default();
apply_most_played_page(&weak, image_cache, rows);
}
/// Set when a play lands in the recently-played store while the Home view is /// Set when a play lands in the recently-played store while the Home view is
/// not showing, so the next Home mount (`HomeActions.home-mounted`) re-reads /// not showing, so the next Home mount (`HomeActions.home-mounted`) re-reads
/// the LOCAL store into the rails. Cleared by `refresh_recent_rails`. /// the LOCAL store into the rails. Cleared by `refresh_recent_rails`.
@@ -15253,6 +15376,29 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
} }
}); });
} }
{
let weak = window.as_weak();
let handle = tokio_rt.handle().clone();
let image_cache = image_cache.clone();
window
.global::<HomeActions>()
.on_open_most_played_albums(move || {
nav::record(nav::NavEntry::MostPlayedAlbums);
navigate_most_played_albums(weak.clone(), &handle, image_cache.clone());
if let Some(w) = weak.upgrade() {
update_nav_flags(&w);
}
});
}
{
let weak = window.as_weak();
let image_cache = image_cache.clone();
window
.global::<MostPlayedAlbumsActions>()
.on_filter(move |q| {
filter_most_played(weak.clone(), image_cache.clone(), q.to_string());
});
}
// Recently-played rails refresh. `home-mounted` fires on every HomeView // Recently-played rails refresh. `home-mounted` fires on every HomeView
// (re)mount: re-read the LOCAL store into the rails IF a play was recorded // (re)mount: re-read the LOCAL store into the rails IF a play was recorded
+3
View File
@@ -55,6 +55,9 @@ pub enum NavEntry {
/// store (crate::recently), reloaded on every navigation, so the entry /// store (crate::recently), reloaded on every navigation, so the entry
/// carries no payload. /// carries no payload.
RecentAlbums, RecentAlbums,
/// MostPlayedAlbumsView — the full "Most Played Albums" listing, ranked by
/// local play count (album_play_history), reloaded on every navigation.
MostPlayedAlbums,
/// A Qobuz mix detail page ("daily" | "weekly" | "fav" | "top"). /// A Qobuz mix detail page ("daily" | "weekly" | "fav" | "top").
Mix { Mix {
kind: String, kind: String,