feat(locallibrary): Artists rail portraits + capped Qobuz photo fetch
Render artist portraits on the two-column Artists rail and fill missing ones
from Qobuz in the background.
- qbz-library: new get_all_artist_image_urls() bulk reader (custom path else
cached Qobuz url, keyed by artist_name) so previously-fetched portraits
reappear on revisit without re-hitting Qobuz. (The Tauri batch command was
never registered; this is the corrected one-pass reader.)
- state.slint: LocalArtistItem gains a decoded `image` field; LocalLibraryState
gains the fetch toggle + progress props. merge_artists now returns a Send-safe
ArtistRow (no slint::Image) across spawn_blocking; apply_artists builds the
LocalArtistItem with the (default-empty) image on the UI thread.
- ensure_artists_loaded: seeds the rail from get_all_artist_image_urls, spawns
decode jobs by scheme (local path -> spawn_local_loads, http -> spawn_loads),
and kicks the capped fetch.
- fetch_missing_artist_images: sequential worker, max 50/session, 1s apart,
generation-guarded, exact-normalized match only (no wrong-artist persist),
paints each portrait immediately, persists via cache_artist_image_with_canonical.
- artwork.rs: Copy-safe LocalArtistRowImage { index, gen } target + apply arm
that resolves index -> name and routes through the new name-keyed dual-setter
set_artist_row_image (flat master + every grouped section), so portraits
survive a derive_artists re-run.
- LocalArtistRow renders the decoded image (placeholder until it lands).
cc
This commit is contained in:
6 files changed
+320
-16
No files matched your search
@@ -4894,6 +4894,42 @@ impl LibraryDatabase {
|
||||
Ok(map)
|
||||
}
|
||||
|
||||
/// Bulk-load every cached artist image (custom path preferred, else the
|
||||
/// fetched Qobuz URL) keyed by artist_name. Lets a UI seed the rail with
|
||||
/// previously-fetched portraits on revisit without re-hitting Qobuz.
|
||||
/// (The Tauri batch command `library_get_artist_images` was never
|
||||
/// registered; this is the corrected one-pass reader.)
|
||||
pub fn get_all_artist_image_urls(
|
||||
&self,
|
||||
) -> Result<std::collections::HashMap<String, String>, LibraryError> {
|
||||
let mut stmt = self
|
||||
.conn
|
||||
.prepare(
|
||||
"SELECT artist_name, custom_image_path, image_url FROM artist_images \
|
||||
WHERE custom_image_path IS NOT NULL OR image_url IS NOT NULL",
|
||||
)
|
||||
.map_err(|e| LibraryError::Database(format!("Failed to prepare query: {}", e)))?;
|
||||
|
||||
let rows = stmt
|
||||
.query_map([], |row| {
|
||||
let custom: Option<String> = row.get(1)?;
|
||||
let url: Option<String> = row.get(2)?;
|
||||
Ok((row.get::<_, String>(0)?, custom.or(url)))
|
||||
})
|
||||
.map_err(|e| {
|
||||
LibraryError::Database(format!("Failed to query artist images: {}", e))
|
||||
})?;
|
||||
|
||||
let mut map = std::collections::HashMap::new();
|
||||
for row in rows.flatten() {
|
||||
let (name, maybe_path) = row;
|
||||
if let Some(path) = maybe_path {
|
||||
map.insert(name, path);
|
||||
}
|
||||
}
|
||||
Ok(map)
|
||||
}
|
||||
|
||||
/// Get all canonical artist names mapping (for bulk lookup)
|
||||
pub fn get_all_canonical_names(
|
||||
&self,
|
||||
|
||||
Reference in new issue
Block a user