Replace the sequential ~9-round-trip load_for_you + monolithic apply_for_you with a progressive, parallel loader. The recently-played sections paint instantly (local, no network); the independent API calls fan out into concurrent branches (release-watch, favorite-artists, favorite-albums, album-suggest) and each section applies the moment its data resolves via upgrade_in_event_loop. The loaded flag is latched only after every branch resolves, so the ensure_for_you_loaded re-entry guard can never strand a partially-loaded tab. Artists to Follow keeps byte-identical dedup/cap semantics (concurrent per-seed fetch via join_all in seed order, then sequential dedup + cap). album-suggest runs concurrently in the common case (recent-album seed), falling back to the first favorite album only when there is no history. The For You skeleton now hides as soon as the first section paints. cc
190 lines
6.3 KiB
Plaintext
190 lines
6.3 KiB
Plaintext
// Discover > For You — dedicated, ordered layout for the For You tab.
|
|
// Unlike Home / Editor's Picks (uniform album carousels from
|
|
// HomeState.sections), For You mixes album carousels, a track
|
|
// carousel, and artist carousels, so it renders from ForYouState.
|
|
// Sections hide themselves when empty.
|
|
//
|
|
// Reuses the shared cards/carousels — no new card components here.
|
|
// Qobuz Mixes, Radio Stations, Spotlight, and the reco-DB sections
|
|
// (More from library, Rediscover) are later increments.
|
|
|
|
import { Theme } from "../foundation/semantic-colors.slint";
|
|
import { Typography } from "../foundation/typography.slint";
|
|
import { ForYouState, RadioStationItem } from "../state.slint";
|
|
import { Carousel } from "Carousel.slint";
|
|
import { SlimCarousel } from "SlimCarousel.slint";
|
|
import { ArtistCarousel } from "ArtistCarousel.slint";
|
|
import { Spotlight } from "Spotlight.slint";
|
|
import { QobuzMixesRow } from "QobuzMixesRow.slint";
|
|
import { RadioCard } from "RadioCard.slint";
|
|
import { HomeSkeleton } from "HomeSkeleton.slint";
|
|
|
|
export component ForYouView inherits VerticalLayout {
|
|
callback open-album(string);
|
|
callback open-artist(string);
|
|
callback media-action(string, string, string);
|
|
callback play-track(string);
|
|
callback play-top-tracks(string);
|
|
callback start-radio(string);
|
|
callback start-radio-album(string);
|
|
callback open-mix(string);
|
|
|
|
// Progressive load: while the first lazy load is in flight, show the
|
|
// skeleton Home uses (the Qobuz Mixes tiles stay — they're static). It
|
|
// hides as soon as ANY content paints — the recently-played sections
|
|
// render first (local, instant), the rest fill in via each section's own
|
|
// `if length > 0` gate. The page-level `loading` latch only keeps the
|
|
// skeleton up while every backing section is still empty.
|
|
property <bool> show-skeleton:
|
|
ForYouState.loading
|
|
&& ForYouState.release-watch.albums.length == 0
|
|
&& ForYouState.top-artists.length == 0
|
|
&& ForYouState.recent-albums.albums.length == 0
|
|
&& ForYouState.recent-tracks.length == 0;
|
|
|
|
spacing: 40px;
|
|
alignment: start;
|
|
|
|
// 0. Qobuz Mixes (static navigation tiles).
|
|
QobuzMixesRow {
|
|
open-mix(which) => {
|
|
root.open-mix(which);
|
|
}
|
|
}
|
|
|
|
if root.show-skeleton: HomeSkeleton { }
|
|
|
|
// 1. Release Watch.
|
|
if ForYouState.release-watch.albums.length > 0: Carousel {
|
|
section: ForYouState.release-watch;
|
|
album-clicked(id) => {
|
|
root.open-album(id);
|
|
}
|
|
media-action(kind, id, action) => {
|
|
root.media-action(kind, id, action);
|
|
}
|
|
}
|
|
|
|
// 1b. Radio Stations — album-seeded radio tiles.
|
|
if ForYouState.radio-stations.length > 0: VerticalLayout {
|
|
spacing: 12px;
|
|
Text {
|
|
text: @tr("Radio Stations");
|
|
color: Theme.text-primary;
|
|
font-size: 18px;
|
|
font-weight: Typography.semibold;
|
|
}
|
|
Rectangle {
|
|
height: 234px;
|
|
clip: true;
|
|
radio-flick := Flickable {
|
|
width: 100%;
|
|
height: parent.height;
|
|
viewport-width: ForYouState.radio-stations.length * (200px + 32px);
|
|
viewport-height: self.height;
|
|
HorizontalLayout {
|
|
spacing: 32px;
|
|
alignment: start;
|
|
for st in ForYouState.radio-stations: RadioCard {
|
|
seed-title: st.title;
|
|
seed-subtitle: st.artist;
|
|
label: "RADIO";
|
|
artwork: st.artwork;
|
|
clicked => {
|
|
root.start-radio-album(st.album-id);
|
|
}
|
|
play => {
|
|
root.start-radio-album(st.album-id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 2. Recently Played Tracks.
|
|
if ForYouState.recent-tracks.length > 0: SlimCarousel {
|
|
title: @tr("Recently Played Tracks");
|
|
items: ForYouState.recent-tracks;
|
|
item-clicked(id) => {
|
|
root.play-track(id);
|
|
}
|
|
}
|
|
|
|
// 3. Recently Played Albums.
|
|
if ForYouState.recent-albums.albums.length > 0: Carousel {
|
|
section: ForYouState.recent-albums;
|
|
album-clicked(id) => {
|
|
root.open-album(id);
|
|
}
|
|
media-action(kind, id, action) => {
|
|
root.media-action(kind, id, action);
|
|
}
|
|
}
|
|
|
|
// 4. Your Top Artists.
|
|
if ForYouState.top-artists.length > 0: ArtistCarousel {
|
|
title: @tr("Your Top Artists");
|
|
artists: ForYouState.top-artists;
|
|
artist-clicked(id) => {
|
|
root.open-artist(id);
|
|
}
|
|
media-action(kind, id, action) => {
|
|
root.media-action(kind, id, action);
|
|
}
|
|
}
|
|
|
|
// 5. More From Your Library.
|
|
if ForYouState.more-from-library.albums.length > 0: Carousel {
|
|
section: ForYouState.more-from-library;
|
|
album-clicked(id) => {
|
|
root.open-album(id);
|
|
}
|
|
media-action(kind, id, action) => {
|
|
root.media-action(kind, id, action);
|
|
}
|
|
}
|
|
|
|
// 6. Rediscover Your Library.
|
|
if ForYouState.rediscover.albums.length > 0: Carousel {
|
|
section: ForYouState.rediscover;
|
|
album-clicked(id) => {
|
|
root.open-album(id);
|
|
}
|
|
media-action(kind, id, action) => {
|
|
root.media-action(kind, id, action);
|
|
}
|
|
}
|
|
|
|
// 6. Artists to Follow.
|
|
if ForYouState.artists-to-follow.length > 0: ArtistCarousel {
|
|
title: @tr("Artists to Follow");
|
|
artists: ForYouState.artists-to-follow;
|
|
artist-clicked(id) => {
|
|
root.open-artist(id);
|
|
}
|
|
media-action(kind, id, action) => {
|
|
root.media-action(kind, id, action);
|
|
}
|
|
}
|
|
|
|
// 6. Spotlight.
|
|
if ForYouState.spotlight-visible: Spotlight {
|
|
open-artist(id) => {
|
|
root.open-artist(id);
|
|
}
|
|
open-album(id) => {
|
|
root.open-album(id);
|
|
}
|
|
play-top-tracks(id) => {
|
|
root.play-top-tracks(id);
|
|
}
|
|
start-radio(id) => {
|
|
root.start-radio(id);
|
|
}
|
|
media-action(kind, id, action) => {
|
|
root.media-action(kind, id, action);
|
|
}
|
|
}
|
|
}
|