From 38c771ad75bbcb657a118acbae1aea6a40281598 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Sat, 23 May 2026 12:17:35 +0200 Subject: [PATCH] fix(web): skip auto-discovery on page load when periodic discovery is disabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When `discovery_enabled` is false the page no longer fires a discovery scan on load. Both DOMContentLoaded handlers now await fetchSettings() and gate triggerDiscovery() on the returned flag — default true keeps existing behaviour for installations that never touched the setting. Also renames the UI label from "Enable Automated Discovery" to "Enable Periodic Discovery" to make clear the checkbox controls the background timer, not the manual trigger button or IP-entry form. Relates to #269 Co-Authored-By: Claude Sonnet 4.6 --- pkg/service/handlers/web/index.html | 2 +- pkg/service/handlers/web/js/script.js | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pkg/service/handlers/web/index.html b/pkg/service/handlers/web/index.html index 7a52d68..143bbfd 100644 --- a/pkg/service/handlers/web/index.html +++ b/pkg/service/handlers/web/index.html @@ -216,7 +216,7 @@ Device Discovery:
diff --git a/pkg/service/handlers/web/js/script.js b/pkg/service/handlers/web/js/script.js index d934f83..baa9e48 100644 --- a/pkg/service/handlers/web/js/script.js +++ b/pkg/service/handlers/web/js/script.js @@ -382,6 +382,7 @@ async function fetchSettings() { fetchLoggingSettings(); fetchSpotifyStatus(); + return settings; } catch (error) { console.error("Failed to fetch settings", error); } @@ -1665,8 +1666,10 @@ function formatXML(xml) { } document.addEventListener("DOMContentLoaded", async () => { - fetchSettings(); - triggerDiscovery(); + const cfg = await fetchSettings(); + if (cfg?.discovery_enabled !== false) { + triggerDiscovery(); + } fetchVersion(); await fetchDevices(); @@ -4051,10 +4054,12 @@ async function applyCustomPlan() { } } -document.addEventListener("DOMContentLoaded", () => { +document.addEventListener("DOMContentLoaded", async () => { fetchDevices(); - fetchSettings(); - triggerDiscovery(); + const cfg = await fetchSettings(); + if (cfg?.discovery_enabled !== false) { + triggerDiscovery(); + } }); // ---------------------------------------------------------------------------