mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-08-28 13:44:35 +00:00
Fix: localStorage preferences take priority over server config
app.js was fetching /api/config/theme and overwriting ROLE_COLORS, ROLE_STYLE, branding AFTER customize.js had already restored them from localStorage. Now skips server overrides for any section where user has local preferences. Also added branding restore from localStorage on DOMContentLoaded.
This commit is contained in:
+9
-6
@@ -510,8 +510,11 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||
fetch('/api/config/theme').then(r => r.json()).then(cfg => {
|
||||
window.SITE_CONFIG = cfg;
|
||||
|
||||
// Apply CSS variable overrides from theme.*
|
||||
if (cfg.theme) {
|
||||
// User's localStorage preferences take priority over server config
|
||||
const userTheme = (() => { try { return JSON.parse(localStorage.getItem('meshcore-user-theme') || '{}'); } catch { return {}; } })();
|
||||
|
||||
// Apply CSS variable overrides from theme.* (server config, skipped if user has local overrides)
|
||||
if (cfg.theme && !userTheme.theme && !userTheme.themeDark) {
|
||||
const root = document.documentElement.style;
|
||||
const varMap = {
|
||||
accent: '--accent', accentHover: '--accent-hover',
|
||||
@@ -533,16 +536,16 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
}
|
||||
|
||||
// Apply node color overrides to ROLE_COLORS and ROLE_STYLE
|
||||
if (cfg.nodeColors) {
|
||||
// Apply node color overrides (skip if user has local preferences)
|
||||
if (cfg.nodeColors && !userTheme.nodeColors) {
|
||||
for (const [role, color] of Object.entries(cfg.nodeColors)) {
|
||||
if (window.ROLE_COLORS && role in window.ROLE_COLORS) window.ROLE_COLORS[role] = color;
|
||||
if (window.ROLE_STYLE && window.ROLE_STYLE[role]) window.ROLE_STYLE[role].color = color;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply branding
|
||||
if (cfg.branding) {
|
||||
// Apply branding (skip if user has local preferences)
|
||||
if (cfg.branding && !userTheme.branding) {
|
||||
if (cfg.branding.siteName) {
|
||||
document.title = cfg.branding.siteName;
|
||||
const brandText = document.querySelector('.brand-text');
|
||||
|
||||
+2
-2
@@ -82,11 +82,11 @@
|
||||
|
||||
<script src="vendor/qrcode.js"></script>
|
||||
<script src="roles.js?v=1774236560"></script>
|
||||
<script src="customize.js?v=1774238059" onerror="console.error('Failed to load:', this.src)"></script>
|
||||
<script src="customize.js?v=1774238281" onerror="console.error('Failed to load:', this.src)"></script>
|
||||
<script src="region-filter.js?v=1774325000"></script>
|
||||
<script src="hop-resolver.js?v=1774223973"></script>
|
||||
<script src="hop-display.js?v=1774221932"></script>
|
||||
<script src="app.js?v=1774234100"></script>
|
||||
<script src="app.js?v=1774238281"></script>
|
||||
<script src="home.js?v=1774236560"></script>
|
||||
<script src="packets.js?v=1774236560"></script>
|
||||
<script src="map.js?v=1774236560" onerror="console.error('Failed to load:', this.src)"></script>
|
||||
|
||||
Reference in New Issue
Block a user