initialize content script vue/ui only if there's a need
This commit is contained in:
parent
9a2261faed
commit
4b177a9724
@ -10,6 +10,7 @@ class Logger {
|
||||
this.isBackgroundScript = true;
|
||||
|
||||
this.vuexStore = options?.vuexStore;
|
||||
this.uwInstance = options?.uwInstance;
|
||||
}
|
||||
|
||||
static saveConfig(conf) {
|
||||
@ -120,6 +121,10 @@ class Logger {
|
||||
});
|
||||
}
|
||||
|
||||
setVuexStore(store) {
|
||||
this.vuexStore = store;
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.log = [];
|
||||
this.startTime = performance.now();
|
||||
@ -295,6 +300,10 @@ class Logger {
|
||||
return false;
|
||||
}
|
||||
|
||||
isLoggingAllowed() {
|
||||
return this.conf.allowLogging;
|
||||
}
|
||||
|
||||
isLoggingToFile() {
|
||||
return this.conf.allowLogging && this.conf.fileOptions?.enabled;
|
||||
}
|
||||
@ -470,9 +479,14 @@ class Logger {
|
||||
}
|
||||
|
||||
if (!this.vuexStore) {
|
||||
console.error("[info] No vue store. Log will not be exported.");
|
||||
console.error("[info] No vue store.");
|
||||
if (!this.uwInstance) {
|
||||
console.error('[info] no vue instance either. Not logging.');
|
||||
return;
|
||||
}
|
||||
console.info("[info] Initializing vue and vuex instance ...");
|
||||
this.uwInstance.initVue();
|
||||
}
|
||||
|
||||
console.info('[info] vuex store present. Parsing logs.');
|
||||
|
||||
|
@ -41,6 +41,8 @@ class UW {
|
||||
this.actionHandler = undefined;
|
||||
this.logger = undefined;
|
||||
this.vuexStore = {};
|
||||
this.uiInitiated = false;
|
||||
this.vueInitiated = false;
|
||||
}
|
||||
|
||||
reloadSettings() {
|
||||
@ -87,9 +89,16 @@ class UW {
|
||||
'handleMouseMove': false
|
||||
}
|
||||
};
|
||||
this.logger = new Logger({vuexStore: this.vuexStore});
|
||||
this.logger = new Logger();
|
||||
await this.logger.init(loggingOptions);
|
||||
|
||||
if (this.logger.isLoggingAllowed()) {
|
||||
console.info("[uw::init] Logging is allowed! Initalizing vue and UI!");
|
||||
this.initVue();
|
||||
this.initUi();
|
||||
this.logger.setVuexStore(this.vuexStore);
|
||||
}
|
||||
|
||||
// show popup if logging to file is enabled
|
||||
if (this.logger.isLoggingToFile()) {
|
||||
console.info('[uw::init] Logging to file is enabled. Will show popup!');
|
||||
@ -228,14 +237,23 @@ class UW {
|
||||
}
|
||||
|
||||
showLogger() {
|
||||
if (! this.vueInitiated) {
|
||||
this.initVue();
|
||||
}
|
||||
if (!this.uiInitiated) {
|
||||
this.initUi();
|
||||
}
|
||||
|
||||
this.vuexStore.dispatch('uw-show-logger');
|
||||
}
|
||||
hideLogger() {
|
||||
// if either of these two is false, then we know that UI doesn't exist
|
||||
// since UI doesn't exist, we don't need to dispatch uw-hide-logger
|
||||
if (this.vueInitiated && this.uiInitiated) {
|
||||
this.vuexStore.dispatch('uw-hide-logger');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var main = new UW();
|
||||
main.initVue();
|
||||
main.initUi();
|
||||
main.init();
|
||||
|
Loading…
Reference in New Issue
Block a user