From 5ed1dec70161deed2877b604863ef93275b29352 Mon Sep 17 00:00:00 2001 From: efiten Date: Wed, 1 Apr 2026 22:43:10 +0200 Subject: [PATCH] fix: reset restores home steps after SITE_CONFIG contamination (closes #325) --- public/app.js | 1 + public/customize.js | 17 +++++++------- public/index.html | 56 ++++++++++++++++++++++----------------------- 3 files changed, 38 insertions(+), 36 deletions(-) diff --git a/public/app.js b/public/app.js index 6e5749fa..bd54467b 100644 --- a/public/app.js +++ b/public/app.js @@ -807,6 +807,7 @@ window.addEventListener('DOMContentLoaded', () => { // User's localStorage preferences take priority over server config const userTheme = (() => { try { return JSON.parse(localStorage.getItem('meshcore-user-theme') || '{}'); } catch { return {}; } })(); + window._SITE_CONFIG_ORIGINAL_HOME = JSON.parse(JSON.stringify(window.SITE_CONFIG.home || {})); mergeUserHomeConfig(window.SITE_CONFIG, userTheme); // Apply CSS variable overrides from theme config (skipped if user has local overrides) diff --git a/public/customize.js b/public/customize.js index c879ebe2..f5cf61ec 100644 --- a/public/customize.js +++ b/public/customize.js @@ -450,7 +450,8 @@ function mergeSection(key) { return Object.assign({}, DEFAULTS[key], cfg[key] || {}, local[key] || {}); } - var mergedHome = mergeSection('home'); + var serverHome = window._SITE_CONFIG_ORIGINAL_HOME || cfg.home || {}; + var mergedHome = Object.assign({}, DEFAULTS.home, serverHome, local.home || {}); var localTsMode = localStorage.getItem('meshcore-timestamp-mode'); var localTsTimezone = localStorage.getItem('meshcore-timestamp-timezone'); var localTsFormat = localStorage.getItem('meshcore-timestamp-format'); @@ -1202,19 +1203,19 @@ var tmp = state.home.steps[i]; state.home.steps[i] = state.home.steps[j]; state.home.steps[j] = tmp; - render(container); + render(container); autoSave(); }); }); container.querySelectorAll('[data-rm-step]').forEach(function (btn) { btn.addEventListener('click', function () { state.home.steps.splice(parseInt(btn.dataset.rmStep), 1); - render(container); + render(container); autoSave(); }); }); var addStepBtn = document.getElementById('addStep'); if (addStepBtn) addStepBtn.addEventListener('click', function () { state.home.steps.push({ emoji: '📌', title: '', description: '' }); - render(container); + render(container); autoSave(); }); // Checklist @@ -1227,13 +1228,13 @@ container.querySelectorAll('[data-rm-check]').forEach(function (btn) { btn.addEventListener('click', function () { state.home.checklist.splice(parseInt(btn.dataset.rmCheck), 1); - render(container); + render(container); autoSave(); }); }); var addCheckBtn = document.getElementById('addCheck'); if (addCheckBtn) addCheckBtn.addEventListener('click', function () { state.home.checklist.push({ question: '', answer: '' }); - render(container); + render(container); autoSave(); }); // Footer links @@ -1246,13 +1247,13 @@ container.querySelectorAll('[data-rm-link]').forEach(function (btn) { btn.addEventListener('click', function () { state.home.footerLinks.splice(parseInt(btn.dataset.rmLink), 1); - render(container); + render(container); autoSave(); }); }); var addLinkBtn = document.getElementById('addLink'); if (addLinkBtn) addLinkBtn.addEventListener('click', function () { state.home.footerLinks.push({ label: '', url: '' }); - render(container); + render(container); autoSave(); }); // Export copy diff --git a/public/index.html b/public/index.html index 55f66d9b..3bc60197 100644 --- a/public/index.html +++ b/public/index.html @@ -22,9 +22,9 @@ - - - + + + @@ -85,30 +85,30 @@
- - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + +