fix(web): skip auto-discovery on page load when periodic discovery is disabled

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 <noreply@anthropic.com>
This commit is contained in:
Tobias Gesellchen
2026-05-23 13:19:46 +02:00
co-authored by Claude Sonnet 4.6
parent 1eb1fefc1d
commit 38c771ad75
2 changed files with 11 additions and 6 deletions
+1 -1
View File
@@ -216,7 +216,7 @@
<strong>Device Discovery:</strong>
<div style="margin-top: 5px">
<label style="display: block; margin-bottom: 5px">
<input type="checkbox" id="discovery-enabled"/> Enable Automated Discovery
<input type="checkbox" id="discovery-enabled"/> Enable Periodic Discovery
</label>
<div style="margin-left: 20px">
<label for="discovery-interval">Discovery Interval:</label>
+10 -5
View File
@@ -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();
}
});
// ---------------------------------------------------------------------------