Owner-directed polish on the Recommendations tab to make it richer + faster + non-repetitive. - Common vs Recent split: the single "Recommended Artists" row over-represented a recent soundtrack binge (a live preview showed "The Newton Brothers" flooding the row with 8 film composers while the core metal was buried). Split into two rows seeded from DIFFERENT periods: "More like the artists you love" (overall top) and "Based on what you've been into lately" (1-month top) — so recent one-offs never pollute the core taste. = 7 rows now. - Round-robin per seed inside each artist row (re-added from the v1 engine; the rework had dropped it) + per-seed cap, so no single seed floods the carousel. - Results cache (48h TTL): caches the FULL built rows (serialized ExternalCarousels) per-user, keyed by connected sources. Tab open within 48h = INSTANT paint from cache, zero fetch; stale/missing = build + store. Rebuilds every 48h (fresh rotation) so it's never "eternally the same" and opens stop being slow. Distinct from the rec->Qobuz resolution cache (30d/7d). - Toast on a real fetch (cache miss/stale): "Generating recommendations…" so the wait is communicated; the skeleton stays; no toast on a cache hit. cargo check -p qbz green (6m44s). cc
153 lines
5.4 KiB
Plaintext
153 lines
5.4 KiB
Plaintext
// Discover > Recommendations — the 4th tab.
|
|
//
|
|
// External-recommendations engine (Last.fm + ListenBrainz -> Qobuz). Artist /
|
|
// album / track carousels, each with a `length > 0` self-hide gate; the
|
|
// controller paints each row the moment its builder resolves (progressive).
|
|
// Data lives in ExternalRecoState (crate::external_reco). Reuses the shared
|
|
// Carousel / ArtistCarousel / SlimCarousel components.
|
|
|
|
import { Theme } from "../foundation/semantic-colors.slint";
|
|
import { Typography } from "../foundation/typography.slint";
|
|
import { ExternalRecoState } from "../state.slint";
|
|
import { Carousel } from "Carousel.slint";
|
|
import { SlimCarousel } from "SlimCarousel.slint";
|
|
import { ArtistCarousel } from "ArtistCarousel.slint";
|
|
import { HomeSkeleton } from "HomeSkeleton.slint";
|
|
|
|
export component ExternalRecoView inherits VerticalLayout {
|
|
callback open-album(string);
|
|
callback open-artist(string);
|
|
callback media-action(string, string, string);
|
|
callback play-track(string);
|
|
|
|
property <bool> any-content:
|
|
ExternalRecoState.rec-artists-common.length > 0
|
|
|| ExternalRecoState.rec-artists-recent.length > 0
|
|
|| ExternalRecoState.rec-albums.albums.length > 0
|
|
|| ExternalRecoState.fresh-releases.albums.length > 0
|
|
|| ExternalRecoState.weekly-exploration.length > 0
|
|
|| ExternalRecoState.weekly-jams.length > 0
|
|
|| ExternalRecoState.deep-cut-albums.albums.length > 0
|
|
|| ExternalRecoState.top-albums.albums.length > 0
|
|
|| ExternalRecoState.top-artists.length > 0;
|
|
|
|
spacing: 40px;
|
|
alignment: start;
|
|
|
|
if ExternalRecoState.loading && !root.any-content: HomeSkeleton { }
|
|
|
|
// More like the artists you love (COMMON taste — overall top).
|
|
if ExternalRecoState.rec-artists-common.length > 0: ArtistCarousel {
|
|
title: @tr("More like the artists you love");
|
|
artists: ExternalRecoState.rec-artists-common;
|
|
artist-clicked(id) => {
|
|
root.open-artist(id);
|
|
}
|
|
media-action(kind, id, action) => {
|
|
root.media-action(kind, id, action);
|
|
}
|
|
}
|
|
|
|
// Based on what you've been into lately (RECENT taste — 1-month top).
|
|
if ExternalRecoState.rec-artists-recent.length > 0: ArtistCarousel {
|
|
title: @tr("Based on what you've been into lately");
|
|
artists: ExternalRecoState.rec-artists-recent;
|
|
artist-clicked(id) => {
|
|
root.open-artist(id);
|
|
}
|
|
media-action(kind, id, action) => {
|
|
root.media-action(kind, id, action);
|
|
}
|
|
}
|
|
|
|
// Recommended Albums (Last.fm artist top-albums, not scrobbled).
|
|
if ExternalRecoState.rec-albums.albums.length > 0: Carousel {
|
|
section: ExternalRecoState.rec-albums;
|
|
album-clicked(id) => {
|
|
root.open-album(id);
|
|
}
|
|
media-action(kind, id, action) => {
|
|
root.media-action(kind, id, action);
|
|
}
|
|
}
|
|
|
|
// Fresh Releases (ListenBrainz, from artists you follow).
|
|
if ExternalRecoState.fresh-releases.albums.length > 0: Carousel {
|
|
section: ExternalRecoState.fresh-releases;
|
|
album-clicked(id) => {
|
|
root.open-album(id);
|
|
}
|
|
media-action(kind, id, action) => {
|
|
root.media-action(kind, id, action);
|
|
}
|
|
}
|
|
|
|
// Weekly Exploration (ListenBrainz discovery playlist).
|
|
if ExternalRecoState.weekly-exploration.length > 0: SlimCarousel {
|
|
title: @tr("Weekly Exploration");
|
|
items: ExternalRecoState.weekly-exploration;
|
|
item-clicked(id) => {
|
|
root.play-track(id);
|
|
}
|
|
}
|
|
|
|
// Weekly Jams (ListenBrainz familiar playlist).
|
|
if ExternalRecoState.weekly-jams.length > 0: SlimCarousel {
|
|
title: @tr("Weekly Jams");
|
|
items: ExternalRecoState.weekly-jams;
|
|
item-clicked(id) => {
|
|
root.play-track(id);
|
|
}
|
|
}
|
|
|
|
// Deep cuts from artists you know (Qobuz catalog albums).
|
|
if ExternalRecoState.deep-cut-albums.albums.length > 0: Carousel {
|
|
section: ExternalRecoState.deep-cut-albums;
|
|
album-clicked(id) => {
|
|
root.open-album(id);
|
|
}
|
|
media-action(kind, id, action) => {
|
|
root.media-action(kind, id, action);
|
|
}
|
|
}
|
|
|
|
// Cold-start fallback — Qobuz editorial top albums.
|
|
if ExternalRecoState.top-albums.albums.length > 0: Carousel {
|
|
section: ExternalRecoState.top-albums;
|
|
album-clicked(id) => {
|
|
root.open-album(id);
|
|
}
|
|
media-action(kind, id, action) => {
|
|
root.media-action(kind, id, action);
|
|
}
|
|
}
|
|
|
|
// Cold-start fallback — Qobuz editorial top artists.
|
|
if ExternalRecoState.top-artists.length > 0: ArtistCarousel {
|
|
title: @tr("Popular artists on Qobuz");
|
|
artists: ExternalRecoState.top-artists;
|
|
artist-clicked(id) => {
|
|
root.open-artist(id);
|
|
}
|
|
media-action(kind, id, action) => {
|
|
root.media-action(kind, id, action);
|
|
}
|
|
}
|
|
|
|
// Empty state.
|
|
if !root.any-content && !ExternalRecoState.loading: VerticalLayout {
|
|
spacing: 8px;
|
|
Text {
|
|
text: @tr("No recommendations yet");
|
|
color: Theme.text-primary;
|
|
font-size: 18px;
|
|
font-weight: Typography.semibold;
|
|
}
|
|
Text {
|
|
text: @tr("Connect Last.fm or ListenBrainz in Settings, or play more music, to get personalized recommendations.");
|
|
color: Theme.text-muted;
|
|
font-size: 13px;
|
|
}
|
|
}
|
|
}
|