From 77567a5eda4f4f3b4fccbaa5fc49472714d2ae0a Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Wed, 22 Apr 2026 19:27:17 -0700 Subject: [PATCH] Sync currentArtistId on library upgrade + hide Similar Artists in Enhanced view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two bugs from the source-artist click flow: 1. After the backend's library upgrade kicks in (clicking a Deezer result for an artist you already own routes through the library path), the response's data.artist.id is the library PK while artistDetailPageState.currentArtistId still held the source id. Toggling Enhanced view then fired /api/library/artist//enhanced which 404'd because the source id isn't a library PK. loadArtistDetailData now updates currentArtistId from data.artist.id whenever they differ — Enhanced view, completion checks, server sync etc. all use the right id. 2. The Similar Artists section is part of the standard view and was staying visible when Enhanced view toggled on. toggleEnhancedView now hides #ad-similar-artists-section in the same flow that hides .discography-sections. --- webui/static/library.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/webui/static/library.js b/webui/static/library.js index 7952fcfc..b5b74d65 100644 --- a/webui/static/library.js +++ b/webui/static/library.js @@ -803,6 +803,18 @@ async function loadArtistDetailData(artistId, artistName) { // Populate the page with data (which updates the hero section and sets textContent) populateArtistDetailPage(data); + // Library upgrade — if the backend resolved this source-artist click to + // an existing library record (e.g. clicking a Deezer result for an + // artist already in your Plex), data.artist.id is the library PK. + // Update currentArtistId so subsequent library-only API calls (Enhanced + // view, completion checks, server sync) hit the right id. Also flip + // the body source flag from 'source' back to 'library' so the + // library-only UI re-shows. + if (data.artist && data.artist.id && String(data.artist.id) !== String(artistDetailPageState.currentArtistId)) { + console.log(`📚 Library upgrade: ${artistDetailPageState.currentArtistId} → ${data.artist.id}`); + artistDetailPageState.currentArtistId = data.artist.id; + } + // Keep the resolved metadata source for album-track lookups. artistDetailPageState.currentArtistSource = data.discography?.source || data.artist?.source || null; @@ -2417,6 +2429,10 @@ function toggleEnhancedView(enabled) { if (i < dividers.length - 1) d.style.display = enabled ? 'none' : ''; }); + // Similar Artists is part of the standard view — hide it in Enhanced. + const similarSection = document.getElementById('ad-similar-artists-section'); + if (similarSection) similarSection.style.display = enabled ? 'none' : ''; + if (enabled) { standardSections.classList.add('hidden'); enhancedContainer.classList.remove('hidden');