fixed modal opening on each refresh
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -7,14 +7,13 @@ export const Config = writable<Record<string, any>>({});
|
||||
export const DisplayUnits = writable<DisplayUnits>();
|
||||
|
||||
let easyAdapterTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
let hasShownEasyAdapter = false;
|
||||
|
||||
export function handleConfigUpdate(config: Record<string, any>) {
|
||||
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<string, any>) {
|
||||
}, 5000);
|
||||
} catch (error) {
|
||||
console.error("Failed to show EasyAdapter dialog:", error);
|
||||
hasShownEasyAdapter = false; // Reset on error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user