Block show-logger until ui is initiated

This commit is contained in:
Tamius Han 2020-03-08 18:38:09 +01:00
parent e681a64f55
commit d8181431ff

View File

@ -4,6 +4,8 @@ import CommsServer from './lib/comms/CommsServer';
import Settings from './lib/Settings'; import Settings from './lib/Settings';
import Logger from './lib/Logger'; import Logger from './lib/Logger';
import sleep from '../common/js/utils';
var BgVars = { var BgVars = {
arIsActive: true, arIsActive: true,
hasVideos: false, hasVideos: false,
@ -50,6 +52,8 @@ class UWServer {
await this.settings.init(); await this.settings.init();
this.comms = new CommsServer(this); this.comms = new CommsServer(this);
this.comms.subscribe('show-logger', async () => await this.initUi()); this.comms.subscribe('show-logger', async () => await this.initUi());
this.comms.subscribe('init-vue', async () => await this.initUi());
var ths = this; var ths = this;
if(BrowserDetect.firefox) { if(BrowserDetect.firefox) {
@ -202,19 +206,19 @@ class UWServer {
async initUi() { async initUi() {
try { try {
if (BrowserDetect.firefox) { if (BrowserDetect.firefox) {
console.log("") await browser.tabs.executeScript({
browser.tabs.executeScript({
file: '/ext/uw-ui.js', file: '/ext/uw-ui.js',
allFrames: true, allFrames: true,
}); });
} else if (BrowserDetect.chrome) { } else if (BrowserDetect.chrome) {
chrome.tabs.executeScript({ await new Promise( resolve =>
file: '/ext/uw-ui.js', chrome.tabs.executeScript({
allFrames: true, file: '/ext/uw-ui.js',
}); allFrames: true,
}, () => resolve())
);
} }
} catch (e) { } catch (e) {
console.error("UI initialization failed. Reason:", e);
this.logger.log('ERROR', 'uwbg', 'UI initialization failed. Reason:', e); this.logger.log('ERROR', 'uwbg', 'UI initialization failed. Reason:', e);
} }
} }