fix(settings): open the right Settings tab from the update link and Race Day
The sidebar update notice now lands on System & backup at Updates, and Race Day's decoder/backend/audio fix buttons open the matching tab, instead of whichever tab was used last. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,14 @@ import { mountAuthSettings } from "./auth_view.js";
|
||||
import { mountTtsSettings } from "./tts_settings_view.js";
|
||||
|
||||
let activeSettingsTab = "connection";
|
||||
let pendingSettingsFocusId = "";
|
||||
|
||||
// Lets other views open Settings on the right tab (and scroll to a section) - e.g. the
|
||||
// sidebar "update available" link lands on System & backup -> Updates.
|
||||
export function openSettingsTab(tabId, focusId = "") {
|
||||
activeSettingsTab = tabId;
|
||||
pendingSettingsFocusId = focusId;
|
||||
}
|
||||
|
||||
function formatBackupSize(bytes) {
|
||||
const value = Math.max(0, Number(bytes || 0));
|
||||
@@ -441,7 +449,7 @@ export function renderSettings(deps) {
|
||||
<div class="panel-body" id="authSettings"></div>
|
||||
</section>
|
||||
|
||||
<section class="panel mt-16">
|
||||
<section class="panel mt-16" id="settingsUpdateSection">
|
||||
<div class="panel-header"><h3>${t("settings.update_title")}</h3></div>
|
||||
<div class="panel-body">
|
||||
<p>${t("settings.update_current_version")}: <strong>v${escapeHtml(String(updateStatus?.currentVersion || ""))}</strong></p>
|
||||
@@ -579,6 +587,10 @@ Erik Eriksson;654321;4WD;Associated;;</code></pre>
|
||||
button.addEventListener("click", () => applySettingsTab(button.dataset.settingsTab));
|
||||
});
|
||||
applySettingsTab(settingsTabButtons.some((button) => button.dataset.settingsTab === activeSettingsTab) ? activeSettingsTab : "connection");
|
||||
if (pendingSettingsFocusId) {
|
||||
document.getElementById(pendingSettingsFocusId)?.scrollIntoView({ block: "start" });
|
||||
pendingSettingsFocusId = "";
|
||||
}
|
||||
mountAuthSettings(document.getElementById("authSettings"), { t, escapeHtml });
|
||||
mountTtsSettings(document.getElementById("ttsSettings"), { state, t, escapeHtml, saveState, speakText });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user