From 77e4671236f7fa809708f68b91c3cab395efc9ca Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Wed, 1 Apr 2026 15:57:26 -0700 Subject: [PATCH] Fix Download Discography button on library artist page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The button called openDiscographyModal() which expected discography data in artistsPageState — but the library page never populated it. Now fetches discography on-demand from /api/artist//discography when called from the library page, using the artist's DB ID and name. --- webui/static/script.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/webui/static/script.js b/webui/static/script.js index 5c20c96a..1d3fc795 100644 --- a/webui/static/script.js +++ b/webui/static/script.js @@ -40949,7 +40949,7 @@ function applyDiscographyFilters() { // ==================== Download Discography Modal ==================== -function openDiscographyModal() { +async function openDiscographyModal() { // Support both Artists search page and Library artist detail page let artist = artistsPageState.selectedArtist; let discography = artistsPageState.artistDiscography; @@ -40961,13 +40961,28 @@ function openDiscographyModal() { const libName = artistDetailPageState.currentArtistName; if (libId && libName) { artist = { id: libId, name: libName, image_url: document.getElementById('artist-detail-image')?.src || '' }; - // Library page stores discography in the same artistsPageState when viewing from library discography = artistsPageState.artistDiscography; + + // If discography not loaded, fetch it on-demand + if (!discography) { + try { + showToast('Loading discography...', 'info'); + const res = await fetch(`/api/artist/${libId}/discography?artist_name=${encodeURIComponent(libName)}`); + const data = await res.json(); + if (data && (data.albums || data.eps || data.singles)) { + discography = data; + artistsPageState.artistDiscography = data; + artistsPageState.selectedArtist = artist; + } + } catch (e) { + console.error('Failed to load discography:', e); + } + } } } if (!artist || !discography) { - showToast('No discography data available', 'error'); + showToast('No discography data available. Artist may not be on Spotify/iTunes.', 'error'); return; }