fix server restart

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-04-03 08:22:43 -04:00
parent 6c29c3fb4d
commit 5bdc87b68a
9 changed files with 25 additions and 12 deletions
+1
View File
@@ -65,6 +65,7 @@ function onOptionsChanged(callback) {
function executeCallbacks(queue, arg) {
// if (!uiLoaded) return
for (const callback of queue) {
if (!callback) continue;
try {
callback(arg);
} catch (e) {
+3 -2
View File
@@ -26,7 +26,7 @@ async function updateOpts(json_string) {
const key = Object.keys(op)[0];
const callback = op[key];
if (opts[key] && opts[key] !== settings_data.values[key]) {
log('updateOpts', key, opts[key], settings_data.values[key]);
log('updateOpt', key, opts[key], settings_data.values[key]);
if (callback) callback(new_opts[key], opts[key]);
}
}
@@ -37,7 +37,8 @@ async function updateOpts(json_string) {
if (callback) callback(new_opts[key], opts[key]);
}
opts = new_opts;
window.opts = new_opts;
log('updateOpts', Object.keys(new_opts).length);
Object.entries(opts_metadata).forEach(([opt, meta]) => {
if (!opts_tabs[meta.tab_name]) opts_tabs[meta.tab_name] = {};
if (!opts_tabs[meta.tab_name].unsaved_keys) opts_tabs[meta.tab_name].unsaved_keys = new Set();
+8 -1
View File
@@ -3,6 +3,7 @@ window.api = '/sdapi/v1';
window.subpath = '';
async function initStartup() {
const t0 = performance.now();
log('initStartup');
if (window.setupLogger) await setupLogger();
@@ -24,7 +25,11 @@ async function initStartup() {
await reconnectUI();
// make sure all of the ui is ready and options are loaded
while (Object.keys(window.opts).length === 0) await sleep(50);
let t1 = performance.now();
while ((Object.keys(window.opts).length === 0) && (t1 - t0 < 10000)) {
t1 = performance.now();
await sleep(50);
}
log('mountURL', window.opts.subpath);
if (window.opts.subpath?.length > 0) {
window.subpath = window.opts.subpath;
@@ -43,6 +48,8 @@ async function initStartup() {
setHints();
applyStyles();
initIndexDB();
t1 = performance.now();
log('initStartup', Math.round(1000 * (t1 - t0) / 1000000));
}
onUiLoaded(initStartup);