Stay in the settings after switching language or demo mode

The language switch reloads the page; it now comes back to the open settings at the same scroll position. Starting the demo selects the demo DSP without leaving the settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
GivouandClaude Opus 5.5 committed 2026-11-01 23:15:57 +01:00
1 parent 5fc745cd72
commit 9473fc9eca
1 file changed
+11 -2
+11 -2
View File
@@ -720,7 +720,7 @@ function lockSection(d) {
async function setDemo(body) { async function setDemo(body) {
try { try {
S.demo = await api("PUT", "/api/demo", body); S.demo = await api("PUT", "/api/demo", body);
if (S.demo.enabled) { S.cur = "demo"; S.settings = false; S.view = "mixer"; } if (S.demo.enabled) S.cur = "demo"; // ready at the top; the settings stay open
render(); render();
} catch (e) { toast(t("Error: ") + trMsg(e.message)); } } catch (e) { toast(t("Error: ") + trMsg(e.message)); }
} }
@@ -1984,6 +1984,8 @@ function langCard() {
if (lang === LANG) return; if (lang === LANG) return;
store.set("dsp.lang", lang); store.set("dsp.lang", lang);
if (S.isApp) await api("PUT", "/api/lang", { lang }).catch(() => {}); if (S.isApp) await api("PUT", "/api/lang", { lang }).catch(() => {});
// the texts are set when the page loads: reload, but come back to the settings where we were
try { sessionStorage.setItem("dsp.reopen", JSON.stringify({ settings: S.settings, y: window.scrollY })); } catch { /* private mode */ }
location.reload(); location.reload();
}; };
return h("div", { class: "card" }, h("h3", {}, "Language / Sprache"), return h("div", { class: "card" }, h("h3", {}, "Language / Sprache"),
@@ -2158,7 +2160,9 @@ function connectEvents() {
if (S.demo.enabled && S.devices.demo && !S.devices[S.cur]?.demo) S.cur = "demo"; if (S.demo.enabled && S.devices.demo && !S.devices[S.cur]?.demo) S.cur = "demo";
S.order.forEach(id => maybeAskUnlock(S.devices[id])); S.order.forEach(id => maybeAskUnlock(S.devices[id]));
if (!S.order.length) S.settings = true; if (!S.order.length) S.settings = true;
render(); break; render();
if (S.reopenY != null) { window.scrollTo(0, S.reopenY); S.reopenY = null; }
break;
case "device": { case "device": {
if (!S.devices[ev.device]) S.order.push(ev.device); if (!S.devices[ev.device]) S.order.push(ev.device);
const was = testOn(S.devices[ev.device]); const was = testOn(S.devices[ev.device]);
@@ -2300,6 +2304,11 @@ async function startApp() {
showMuteAll(); showMuteAll();
if (S.isApp) S.remote = await api("GET", "/api/remote"); if (S.isApp) S.remote = await api("GET", "/api/remote");
} catch { /* plain web UI */ } } catch { /* plain web UI */ }
try { // after a language switch: back to the settings and the scroll position
const r = JSON.parse(sessionStorage.getItem("dsp.reopen") || "null");
sessionStorage.removeItem("dsp.reopen");
if (r && r.settings) { S.settings = true; S.reopenY = r.y || 0; }
} catch { /* private mode */ }
connectEvents(); connectEvents();
} }