diff --git a/src/py/bbctrl/Web.py b/src/py/bbctrl/Web.py index 47f1d57..1af8d54 100644 --- a/src/py/bbctrl/Web.py +++ b/src/py/bbctrl/Web.py @@ -1,6 +1,7 @@ import os import json import tornado +import time import sockjs.tornado import datetime import subprocess @@ -250,7 +251,14 @@ class PasswordHandler(bbctrl.APIHandler): class ConfigLoadHandler(bbctrl.APIHandler): def get(self): - self.write_json(self.get_ctrl().config.load()) + config = self.get_ctrl().config.load() + + # Check if we're within the first 90 seconds of server boot + web_app = self.application + time_since_boot = time.time() - web_app.server_boot_time + config['_server_first_load'] = time_since_boot <= 90.0 # True if within first 90 seconds + + self.write_json(config) class ConfigDownloadHandler(bbctrl.APIHandler): @@ -878,6 +886,7 @@ class Web(tornado.web.Application): self.args = args self.ioloop = ioloop self.ctrls = {} + self.server_boot_time = time.time() # Track when server started # Init camera if not args.disable_camera: diff --git a/src/svelte-components/src/lib/ConfigStore.ts b/src/svelte-components/src/lib/ConfigStore.ts index ac83865..fd60bf6 100644 --- a/src/svelte-components/src/lib/ConfigStore.ts +++ b/src/svelte-components/src/lib/ConfigStore.ts @@ -7,14 +7,13 @@ export const Config = writable>({}); export const DisplayUnits = writable(); let easyAdapterTimer: ReturnType | null = null; -let hasShownEasyAdapter = false; export function handleConfigUpdate(config: Record) { Config.set(config); - // Check if easy-adapter is enabled and show dialog on app load - if (config.settings && config.settings["easy-adapter"] && !hasShownEasyAdapter) { - hasShownEasyAdapter = true; + // Check if easy-adapter is enabled and show dialog if within first 90 seconds of server boot + // The server provides a _server_first_load flag that is true for all requests within first 90 seconds of server startup + if (config.settings && config.settings["easy-adapter"] && config._server_first_load) { try { // Clear any existing timer first @@ -38,7 +37,6 @@ export function handleConfigUpdate(config: Record) { }, 5000); } catch (error) { console.error("Failed to show EasyAdapter dialog:", error); - hasShownEasyAdapter = false; // Reset on error } } }