From c944ed03737915b0b5bca1e81316372ddc54b67a Mon Sep 17 00:00:00 2001 From: javalikescript Date: Sun, 26 Jan 2025 09:42:20 +0100 Subject: [PATCH] Wait addons to boot --- extensions/web-base/www/app/app.js | 1 - extensions/web-base/www/app/boot.js | 21 ++++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/extensions/web-base/www/app/app.js b/extensions/web-base/www/app/app.js index dccfd63..9ec0da5 100644 --- a/extensions/web-base/www/app/app.js +++ b/extensions/web-base/www/app/app.js @@ -224,7 +224,6 @@ var app = new Vue({ case 'addon-change': if (this.reloadTimeoutId) { clearTimeout(this.reloadTimeoutId); - this.reloadTimeoutId = undefined; } this.reloadTimeoutId = setTimeout(function () { toaster.toast('Reloading...'); diff --git a/extensions/web-base/www/app/boot.js b/extensions/web-base/www/app/boot.js index d7d4c70..6734982 100644 --- a/extensions/web-base/www/app/boot.js +++ b/extensions/web-base/www/app/boot.js @@ -79,22 +79,29 @@ Promise.all([ fetch('addon/').then(rejectIfNotOk).then(getJson), fetch('/engine/user').then(rejectIfNotOk).then(getJson), ]).then(apply(this, function(webBaseConfig, addons, user) { + var theme = webBaseConfig.theme || 'default' if (webBaseConfig.title) { document.title = webBaseConfig.title; homePage.title = webBaseConfig.title; } - app.setTheme(webBaseConfig.theme || 'default'); app.user = user; - onHashchange(); - setupWebSocket(); if (Array.isArray(addons)) { return Promise.all(addons.map(function(addon) { console.log('loading addon ' + addon.id); return new Promise(function(resolve) { require(['addon/' + addon.id + '/' + addon.script], resolve); - }) - })); + }); + })).then(function() { + console.info('addons loaded'); + }, function() { + console.info('fail to load addons'); + }).then(function() { + return theme; + }); } -})).then(function() { - console.info('addons loaded'); + return theme; +})).then(function(theme) { + app.setTheme(theme); + onHashchange(); + setupWebSocket(); });