web: cache repeater title across app and stats pages

Этот коммит содержится в:
Jared Dohrman
2026-04-18 11:17:49 +10:00
родитель d00fc588d3
Коммит 663f493817
+15 -1
Просмотреть файл
@@ -994,6 +994,7 @@ const char kWebPanelAppHtml[] PROGMEM = R"HTML(
const RADIO_PRESETS_URL = "https://api.meshcore.nz/api/v1/config"; const RADIO_PRESETS_URL = "https://api.meshcore.nz/api/v1/config";
const isStatsPage = window.location.pathname === "/stats"; const isStatsPage = window.location.pathname === "/stats";
const LAST_PAGE_KEY = "repeater-last-page"; const LAST_PAGE_KEY = "repeater-last-page";
const PANEL_TITLE_KEY = "repeater-panel-title";
let token = sessionStorage.getItem("repeater-token") || ""; let token = sessionStorage.getItem("repeater-token") || "";
let commandQueue = Promise.resolve(); let commandQueue = Promise.resolve();
let radioPresetEntries = []; let radioPresetEntries = [];
@@ -1005,7 +1006,19 @@ const char kWebPanelAppHtml[] PROGMEM = R"HTML(
function updatePanelTitle(nameValue) { function updatePanelTitle(nameValue) {
const fallbackTitle = "Repeater Config"; const fallbackTitle = "Repeater Config";
const trimmedName = String(nameValue == null ? "" : nameValue).trim(); const trimmedName = String(nameValue == null ? "" : nameValue).trim();
document.title = trimmedName ? trimmedName : fallbackTitle; const nextTitle = trimmedName ? trimmedName : fallbackTitle;
document.title = nextTitle;
if (trimmedName) {
localStorage.setItem(PANEL_TITLE_KEY, trimmedName);
} else {
localStorage.removeItem(PANEL_TITLE_KEY);
}
}
function applyCachedPanelTitle() {
const cachedTitle = localStorage.getItem(PANEL_TITLE_KEY);
if (cachedTitle && cachedTitle.trim()) {
document.title = cachedTitle.trim();
}
} }
function rememberCurrentPage() { function rememberCurrentPage() {
localStorage.setItem(LAST_PAGE_KEY, isStatsPage ? "/stats" : "/app"); localStorage.setItem(LAST_PAGE_KEY, isStatsPage ? "/stats" : "/app");
@@ -1017,6 +1030,7 @@ const char kWebPanelAppHtml[] PROGMEM = R"HTML(
window.location.replace("/"); window.location.replace("/");
} }
rememberCurrentPage(); rememberCurrentPage();
applyCachedPanelTitle();
function getPreferredTheme() { function getPreferredTheme() {
const saved = localStorage.getItem("repeater-theme"); const saved = localStorage.getItem("repeater-theme");
if (saved === "light" || saved === "dark") return saved; if (saved === "light" || saved === "dark") return saved;