From 3fb69d8595140ea6066800290dbbd566df1376d5 Mon Sep 17 00:00:00 2001 From: Job Date: Fri, 17 Jul 2026 20:33:47 +0200 Subject: [PATCH] fix: read auto-filter setting in onV3SongsScreenEnter, not render() render() is cached/skipped on return visits to the library when the DOM hash matches. Moved the settings read to onV3SongsScreenEnter which always runs on screen entry, so the toggle change is picked up immediately even without a full re-render. --- static/v3/songs.js | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/static/v3/songs.js b/static/v3/songs.js index c3cdfd9..811ed2d 100644 --- a/static/v3/songs.js +++ b/static/v3/songs.js @@ -3651,25 +3651,17 @@ // toolbar so its selects reflect the saved choice (default: Artist A–Z). if (!_prefsRestored) { applySavedPrefs(); _prefsRestored = true; } // ── Auto-apply instrument arrangement filter on first render ───── - // Always read the auto-filter toggle from settings so the user can - // enable/disable it in Settings → Gameplay without a full page reload. - try { - var sr = await fetch('/api/settings'); - if (sr.ok) { - var sd = await sr.json(); - _autoFilterEnabled = sd.auto_filter_instrument !== false; - } - } catch (_) {} + // auto_filter_instrument setting is already refreshed in + // onV3SongsScreenEnter before render() is called. if (_autoFilterEnabled && _arrAutoInstrument === null && !state.filters.arr_has.length && !state.filters.arr_lacks.length) { try { - var instId = sd && sd.instrument; - if (instId) _applyArrangementAutoFilter(instId); + var sr2 = await fetch('/api/settings'); + if (sr2.ok) { + var sd2 = await sr2.json(); + var instId = sd2 && sd2.instrument; + if (instId) _applyArrangementAutoFilter(instId); + } } catch (_) {} - } else if (!_autoFilterEnabled && state.filters.arr_has.length) { - // Toggle was turned off — clear any previously-applied auto-filter. - state.filters.arr_has = []; - state.filters.arr_lacks = []; - _arrAutoInstrument = null; } const providers = await loadProviders(); const [, tn] = await Promise.all([ @@ -3843,6 +3835,26 @@ } async function onV3SongsScreenEnter() { + // Always refresh the auto-filter toggle state so the user can + // enable/disable it in Settings without a full page reload. + try { + var sr = await fetch('/api/settings'); + if (sr.ok) { + var sd = await sr.json(); + _autoFilterEnabled = sd.auto_filter_instrument !== false; + // If the toggle was turned off, clear any previously-applied filter. + if (!_autoFilterEnabled && state.filters.arr_has.length) { + state.filters.arr_has = []; + state.filters.arr_lacks = []; + _arrAutoInstrument = null; + } + // If the toggle was turned on and no filter is active, apply it. + if (_autoFilterEnabled && _arrAutoInstrument === null && !state.filters.arr_has.length && !state.filters.arr_lacks.length) { + var instId = sd && sd.instrument; + if (instId) _applyArrangementAutoFilter(instId); + } + } + } catch (_) {} // A library scan / DLC-folder change marked the grid stale — re-fetch // from scratch instead of restoring a cached (possibly empty, pre-DLC) // snapshot. Must win over every fast-path below.