From cd715f8697a16e17e28c1a346f0ff10aa998a1c0 Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Sun, 17 May 2026 23:40:39 -0700 Subject: [PATCH] Preserve source when opening artist detail --- webui/static/discover.js | 55 ++++++++++++++++++++++++++-------- webui/static/downloads.js | 4 ++- webui/static/shared-helpers.js | 1 + webui/static/sync-spotify.js | 3 +- 4 files changed, 49 insertions(+), 14 deletions(-) diff --git a/webui/static/discover.js b/webui/static/discover.js index 3142a22b..aa22b3aa 100644 --- a/webui/static/discover.js +++ b/webui/static/discover.js @@ -387,6 +387,7 @@ async function watchAllHeroArtists(btn) { // Cache for recommended artists data so reopening is instant let _recommendedArtistsCache = null; +let _recommendedArtistsSource = null; async function openRecommendedArtistsModal() { let modal = document.getElementById('recommended-artists-modal'); @@ -404,7 +405,7 @@ async function openRecommendedArtistsModal() { // If cached, render instantly and refresh watchlist statuses if (_recommendedArtistsCache) { modal.style.display = 'flex'; - renderRecommendedArtistsModal(modal, _recommendedArtistsCache); + renderRecommendedArtistsModal(modal, _recommendedArtistsCache, _recommendedArtistsSource); checkRecommendedWatchlistStatuses(_recommendedArtistsCache); return; } @@ -444,13 +445,14 @@ async function openRecommendedArtistsModal() { return; } - // Render cards immediately with fallback images - _recommendedArtistsCache = data.artists; - renderRecommendedArtistsModal(modal, data.artists); - // Phase 2: Enrich with images/genres progressively in batches of 50 // Skip artists that already have cached metadata from the initial response const source = data.source || 'spotify'; + // Render cards immediately with fallback images + _recommendedArtistsCache = data.artists; + _recommendedArtistsSource = source; + renderRecommendedArtistsModal(modal, data.artists, source); + const idKey = source === 'spotify' ? 'spotify_artist_id' : source === 'deezer' ? 'deezer_artist_id' : 'itunes_artist_id'; const allIds = data.artists .filter(a => !a.image_url) // Only enrich artists without cached images @@ -521,7 +523,7 @@ async function openRecommendedArtistsModal() { } } -function renderRecommendedArtistsModal(modal, artists) { +function renderRecommendedArtistsModal(modal, artists, source = null) { modal.innerHTML = `