Fix: artist detail forced Enhanced view on source-only artists, hiding discog

The persisted Standard/Enhanced preference was re-applied on every artist load
BEFORE the data came back — so for an artist not in the library (source-only, no
Enhanced view) it still flipped to Enhanced, which showed an empty Enhanced pane
and never rendered the discography.

Now the preference is applied inside loadArtistDetailData, after we know the
artist's status (data.artist.server_source). Only library artists honour a saved
'enhanced' choice; source-only artists always stay on Standard (discography).
This commit is contained in:
BoulderBadgeDad 2026-06-03 13:40:00 -07:00
parent b0c0acb379
commit ed2a97d701

View file

@ -879,15 +879,6 @@ function navigateToArtistDetail(artistId, artistName, sourceOverride = null, opt
const bulkBar = document.getElementById('enhanced-bulk-bar');
if (bulkBar) bulkBar.classList.remove('visible');
// Restore persisted view preference. Non-admins can't see / toggle the
// Enhanced control so only honour the saved choice for admins; default
// is still Standard. Wrapped in try/catch because localStorage can be
// disabled in private-browsing modes.
let _preferEnhanced = false;
try {
_preferEnhanced = localStorage.getItem(_libraryViewModeKey()) === 'enhanced';
} catch (_) { /* localStorage unavailable */ }
// Navigate to artist detail page
navigateToPage('artist-detail', {
artistId,
@ -902,15 +893,11 @@ function navigateToArtistDetail(artistId, artistName, sourceOverride = null, opt
_updateArtistDetailBackButtonLabel();
// Load artist data
// Load artist data. The persisted Enhanced-view preference is applied INSIDE
// loadArtistDetailData, once we know whether this artist is in the library —
// source-only artists have no Enhanced view, so forcing it there left the
// Enhanced pane empty and hid the discography.
loadArtistDetailData(artistId, artistName);
// Apply persisted Enhanced view after the standard data load is kicked off.
// toggleEnhancedView() triggers its own loadEnhancedViewData() in parallel;
// the brief Standard render is hidden as soon as the toggle flips.
if (_preferEnhanced && isEnhancedAdmin()) {
toggleEnhancedView(true);
}
}
function _updateArtistDetailBackButtonLabel() {
@ -1095,6 +1082,18 @@ async function loadArtistDetailData(artistId, artistName) {
checkArtistEnhanceEligibility(artistDetailPageState.currentArtistId);
}
// Apply the persisted Enhanced/Standard preference now that we know the
// artist's status. Only LIBRARY artists have an Enhanced view — forcing
// it on a source-only artist (no DB record) showed an empty Enhanced pane
// and hid the discography. Source-only artists always stay on Standard.
if (!isSourceOnlyArtist && isEnhancedAdmin()) {
let _preferEnhanced = false;
try {
_preferEnhanced = localStorage.getItem(_libraryViewModeKey()) === 'enhanced';
} catch (_) { /* localStorage unavailable */ }
if (_preferEnhanced) toggleEnhancedView(true);
}
} catch (error) {
console.error(`❌ Error loading artist detail data:`, error);