feat: cover art cache, Collection tabs, and album, artist and playlist pages

- ym-api: album/artist/playlist summaries and pages, liked albums and
  artists, own and liked playlists (batch-resolved from like ids),
  playlist tracks with missing ones looked up, image download
- Cover cache: fetched when a cover nears the viewport (sensor), at most
  eight at once, kept in memory and on disk; arrivals are batched every
  150 ms so cached lists rebuild once per batch
- Collection tabs for liked tracks, albums, artists and playlists, each
  loading on first visit with a retry on failure
- Album, Artist and Playlist routes with cover headers, Play/Shuffle and
  track lists; pages cached per session; sidebar lists playlists
- Shared lazy track list keyed on contents, playing track, likes and
  cover version; card grid that wraps
This commit is contained in:
Yuriy Panov committed 2026-10-15 14:51:51 +06:00
1 parent b73af1f870
commit 3b934df8cc
22 files changed
+1773 -247

No files matched your search

+15 -9
View File
@@ -72,10 +72,7 @@ impl Track {
/// "Artist A, Artist B", or "Unknown artist".
pub fn artist_line(&self) -> String {
if self.artists.is_empty() {
return "Unknown artist".into();
}
self.artists.iter().map(|a| a.name.as_str()).collect::<Vec<_>>().join(", ")
crate::library::join_names(&self.artists)
}
/// Title with its version: "Song (Live)".
@@ -88,20 +85,29 @@ impl Track {
/// Absolute cover URL at `size`×`size` pixels.
pub fn cover_url(&self, size: u32) -> Option<String> {
let uri = self.cover_uri.as_deref()?;
Some(yamuse::models::normalize_image_url(uri, &format!("{size}x{size}")))
cover_url(self.cover_uri.as_deref(), size)
}
/// Two stable hues for placeholder art, derived from the album (or track) id.
pub fn hues(&self) -> (f32, f32) {
let seed = self.album.as_ref().map_or_else(
hues_for(self.album.as_ref().map_or_else(
|| self.id.bytes().fold(7u64, |h, b| h.wrapping_mul(31).wrapping_add(u64::from(b))),
|a| a.id as u64,
);
((seed.wrapping_mul(47) % 360) as f32, (seed.wrapping_mul(131).wrapping_add(90) % 360) as f32)
))
}
}
/// Absolute URL for a `%%`-templated image uri at `size`×`size` pixels.
pub(crate) fn cover_url(uri: Option<&str>, size: u32) -> Option<String> {
let uri = uri.filter(|u| !u.is_empty())?;
Some(yamuse::models::normalize_image_url(uri, &format!("{size}x{size}")))
}
/// Two hues for placeholder art; equal seeds give equal art.
pub(crate) fn hues_for(seed: u64) -> (f32, f32) {
((seed.wrapping_mul(47) % 360) as f32, (seed.wrapping_mul(131).wrapping_add(90) % 360) as f32)
}
/// Where a track's audio comes from.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Stream {