fixed modal opening on each refresh
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import tornado
|
import tornado
|
||||||
|
import time
|
||||||
import sockjs.tornado
|
import sockjs.tornado
|
||||||
import datetime
|
import datetime
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -250,7 +251,14 @@ class PasswordHandler(bbctrl.APIHandler):
|
|||||||
|
|
||||||
class ConfigLoadHandler(bbctrl.APIHandler):
|
class ConfigLoadHandler(bbctrl.APIHandler):
|
||||||
def get(self):
|
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):
|
class ConfigDownloadHandler(bbctrl.APIHandler):
|
||||||
@@ -878,6 +886,7 @@ class Web(tornado.web.Application):
|
|||||||
self.args = args
|
self.args = args
|
||||||
self.ioloop = ioloop
|
self.ioloop = ioloop
|
||||||
self.ctrls = {}
|
self.ctrls = {}
|
||||||
|
self.server_boot_time = time.time() # Track when server started
|
||||||
|
|
||||||
# Init camera
|
# Init camera
|
||||||
if not args.disable_camera:
|
if not args.disable_camera:
|
||||||
|
|||||||
@@ -7,14 +7,13 @@ export const Config = writable<Record<string, any>>({});
|
|||||||
export const DisplayUnits = writable<DisplayUnits>();
|
export const DisplayUnits = writable<DisplayUnits>();
|
||||||
|
|
||||||
let easyAdapterTimer: ReturnType<typeof setTimeout> | null = null;
|
let easyAdapterTimer: ReturnType<typeof setTimeout> | null = null;
|
||||||
let hasShownEasyAdapter = false;
|
|
||||||
|
|
||||||
export function handleConfigUpdate(config: Record<string, any>) {
|
export function handleConfigUpdate(config: Record<string, any>) {
|
||||||
Config.set(config);
|
Config.set(config);
|
||||||
|
|
||||||
// Check if easy-adapter is enabled and show dialog on app load
|
// Check if easy-adapter is enabled and show dialog if within first 90 seconds of server boot
|
||||||
if (config.settings && config.settings["easy-adapter"] && !hasShownEasyAdapter) {
|
// The server provides a _server_first_load flag that is true for all requests within first 90 seconds of server startup
|
||||||
hasShownEasyAdapter = true;
|
if (config.settings && config.settings["easy-adapter"] && config._server_first_load) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Clear any existing timer first
|
// Clear any existing timer first
|
||||||
@@ -38,7 +37,6 @@ export function handleConfigUpdate(config: Record<string, any>) {
|
|||||||
}, 5000);
|
}, 5000);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to show EasyAdapter dialog:", error);
|
console.error("Failed to show EasyAdapter dialog:", error);
|
||||||
hasShownEasyAdapter = false; // Reset on error
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user