mirror of
https://github.com/got-feedBack/feedBack.git
synced 2026-07-27 23:31:54 +00:00
fix: always read auto-filter setting, not just on first render
_autoFilterEnabled was only read inside the _arrAutoInstrument===null block, so it never updated on subsequent library visits after the first one. Now the settings fetch runs on every render() call. When the toggle is OFF, any previously-applied auto-filter is cleared.
This commit is contained in:
parent
40b3f010e0
commit
180633b033
@ -3651,19 +3651,25 @@
|
||||
// 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 ─────
|
||||
if (_arrAutoInstrument === null && !state.filters.arr_has.length && !state.filters.arr_lacks.length) {
|
||||
// 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 (_) {}
|
||||
if (_autoFilterEnabled && _arrAutoInstrument === null && !state.filters.arr_has.length && !state.filters.arr_lacks.length) {
|
||||
try {
|
||||
var sr = await fetch('/api/settings');
|
||||
if (sr.ok) {
|
||||
var sd = await sr.json();
|
||||
var instId = sd && sd.instrument;
|
||||
// Respect the auto-filter toggle in Gameplay settings.
|
||||
var autoFilter = sd.auto_filter_instrument !== false;
|
||||
_autoFilterEnabled = autoFilter;
|
||||
console.log('auto-filter: initial render instrument=' + instId + ' enabled=' + autoFilter + ' raw=' + sd.auto_filter_instrument);
|
||||
if (instId && autoFilter) _applyArrangementAutoFilter(instId);
|
||||
}
|
||||
var instId = sd && sd.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([
|
||||
@ -4312,7 +4318,6 @@
|
||||
// on the next instrument switch.
|
||||
sm.on('instrument:changed', function (e) {
|
||||
var instId = e && e.detail && e.detail.instrument;
|
||||
console.log('auto-filter: instrument=' + instId + ' enabled=' + _autoFilterEnabled);
|
||||
if (!instId || !_autoFilterEnabled) return;
|
||||
if (_applyArrangementAutoFilter(instId)) {
|
||||
reload();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user