fix(library): load artists before navigating from album view

When clicking artist link from album view, ensure artists are loaded
before switching to artists tab. This fixes empty page on first visit.
This commit is contained in:
vicrodh committed 2026-01-28 13:10:11 -06:00
1 parent 2ad92a5854
commit e97a2ed86f
1 file changed
+8 -4
@@ -2212,7 +2212,7 @@
return (exactMatch ?? results.items[0]).id; return (exactMatch ?? results.items[0]).id;
} }
function handleLocalArtistClick(name?: string) { async function handleLocalArtistClick(name?: string) {
if (!name) return; if (!name) return;
if (normalizeArtistName(name) === 'various artists') return; if (normalizeArtistName(name) === 'various artists') return;
@@ -2225,20 +2225,24 @@
// Switch to artists tab // Switch to artists tab
activeTab = 'artists'; activeTab = 'artists';
// Load artists if not already loaded
if (artists.length === 0) {
await loadArtists();
}
// Select artist to show their albums in the right column // Select artist to show their albums in the right column
selectedArtistName = name; selectedArtistName = name;
// Scroll to the artist card after DOM updates // Scroll to the artist card after DOM updates
// Use multiple ticks + small delay to ensure content is fully rendered // Use multiple ticks + small delay to ensure content is fully rendered
tick().then(() => { await tick();
setTimeout(() => { setTimeout(() => {
const artistId = `local-artist-${normalizeArtistName(name)}`; const artistId = `local-artist-${normalizeArtistName(name)}`;
const artistCard = document.getElementById(artistId); const artistCard = document.getElementById(artistId);
if (artistCard) { if (artistCard) {
artistCard.scrollIntoView({ behavior: 'smooth', block: 'center' }); artistCard.scrollIntoView({ behavior: 'smooth', block: 'center' });
} }
}, 100); }, 150);
});
} }
/** /**