From 27e765cc832263bdf8f775c8822cc15b513d5273 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Fri, 20 Feb 2026 04:02:01 -0600 Subject: [PATCH] fix(label): fetch artist images, section spacing, scroll offset - Fetch artist images via v2_get_artist for artists without images from the label page data (parallel fetches with fallback) - Add 20px extra spacing between sections - Add scroll-margin-top to section anchors so jump-nav doesn't cover section titles when clicking nav links --- src/lib/components/views/LabelView.svelte | 40 +++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/lib/components/views/LabelView.svelte b/src/lib/components/views/LabelView.svelte index 3cd0bcb99..712384e53 100644 --- a/src/lib/components/views/LabelView.svelte +++ b/src/lib/components/views/LabelView.svelte @@ -107,6 +107,9 @@ let artists = $state[]>([]); let moreLabels = $state([]); + // Artist image cache (fetched via v2_get_artist) + let artistImageMap = $state>(new Map()); + // Track expand state (like ArtistDetailView: 5 → 20 → 50) let visibleTracksCount = $state(5); let showTracksContextMenu = $state(false); @@ -338,6 +341,27 @@ } } + async function loadArtistImages(artistList: Record[]) { + // Fetch images for artists that don't have them from the label page data + const fetches = artistList.map(async (artist) => { + const id = artist.id as number; + // Skip if we already have a local image from the label page data + if (getArtistImageUrl(artist)) return; + try { + const detail = await invoke<{ image?: { small?: string; thumbnail?: string; large?: string } }>( + 'v2_get_artist', { artistId: id } + ); + const url = detail?.image?.large || detail?.image?.thumbnail || detail?.image?.small; + if (url) { + artistImageMap = new Map([...artistImageMap, [id, url]]); + } + } catch { + // Silently skip — placeholder will show + } + }); + await Promise.allSettled(fetches); + } + // Track playback — mirrors ArtistDetailView exactly function buildTopTracksQueue(tracks: Track[]) { return tracks.map((track) => ({ @@ -473,6 +497,9 @@ } function getArtistImageUrl(artist: Record): string | null { + // 0. Check fetched image cache + const cached = artistImageMap.get(artist.id as number); + if (cached) return cached; // 1. image object (most common in search results) const image = artist.image as Record | null | undefined; if (image && typeof image === 'object') { @@ -576,6 +603,7 @@ artists = []; moreLabels = []; labelDescription = null; + artistImageMap = new Map(); loadLabelPage(); loadLabelAlbumsAndDescription(); loadMoreLabels(); @@ -588,6 +616,13 @@ } }); + // Fetch artist images when artists are loaded + $effect(() => { + if (artists.length > 0) { + loadArtistImages(artists); + } + }); + // Jump-nav IntersectionObserver $effect(() => { if (!labelDetailEl) return; @@ -1147,7 +1182,8 @@ .read-more-btn:hover { text-decoration: underline; } /* Sections */ - .section { margin-bottom: 8px; } + .section-anchor { scroll-margin-top: 56px; } + .section { margin-bottom: 28px; } .section-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; @@ -1190,7 +1226,7 @@ .context-menu-item:hover { background-color: var(--bg-hover); color: var(--text-primary); } /* Tracks */ - .top-tracks-section { margin-bottom: 32px; } + .top-tracks-section { margin-bottom: 48px; } .tracks-list { display: flex; flex-direction: column; } .track-row { display: flex; align-items: center; gap: 12px;