[fix](trx-frontend-http): directly re-apply bookmark chip colors on theme change

Bumping bmRevision and scheduling a spectrum draw was not enough because
the spectrum draw path only runs when spectrum data is present. Instead,
directly update --bm-cat-bg/--bm-cat-fg on all existing bookmark chips
from the new theme palette so colors update immediately.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
2026-03-22 09:29:50 +01:00
parent 4d09636793
commit 2d1f635019
@@ -631,7 +631,21 @@ function setTheme(theme) {
themeToggleBtn.title = next === "dark" ? "Switch to light mode" : "Switch to dark mode"; themeToggleBtn.title = next === "dark" ? "Switch to light mode" : "Switch to dark mode";
} }
// Invalidate cached bookmark chip colours so they pick up the new theme palette. // Invalidate cached bookmark chip colours so they pick up the new theme palette.
if (typeof bmRevision !== "undefined") bmRevision++; if (typeof bmRevision !== "undefined") {
bmRevision++;
// Re-apply colours to existing bookmark chips using the new palette.
try {
const colorMap = bmCategoryColorMap();
const ref = typeof bmList !== "undefined" ? bmList : [];
document.querySelectorAll(".spectrum-bookmark-chip").forEach((chip) => {
const bm = ref.find((b) => b.id === chip.dataset.bmId);
if (!bm) return;
const col = colorMap[bm.category || ""] || BOOKMARK_MARKER_FALLBACK;
chip.style.setProperty("--bm-cat-bg", col);
chip.style.setProperty("--bm-cat-fg", bmContrastFg(col));
});
} catch (_) {}
}
try { if (typeof scheduleSpectrumDraw === "function") scheduleSpectrumDraw(); } catch (_) {} try { if (typeof scheduleSpectrumDraw === "function") scheduleSpectrumDraw(); } catch (_) {}
} }