Fix logging popup a bit

This commit is contained in:
Tamius Han 2021-08-24 02:13:05 +02:00
parent 981da95cde
commit a234903b8f
3 changed files with 53 additions and 11 deletions

View File

@ -276,6 +276,8 @@ export default {
this.logStringified = undefined;
}
this.$store.dispatch('uw-hide-logger');
this.showLoggerUi = false;
},
closePopupAndStopLogging() {
Logger.saveConfig({...this.lastSettings, allowLogging: false});

View File

@ -314,23 +314,31 @@ class ActionHandler {
handleKeyup(event) {
this.logger.log('info', 'keyboard', "%c[ActionHandler::handleKeyup] we pressed a key: ", "color: #ff0", event.key , " | keyup: ", event.keyup, "event:", event);
if (this.preventAction(event)) {
this.logger.log('info', 'keyboard', "[ActionHandler::handleKeyup] we are in a text box or something. Doing nothing.");
return;
}
try {
if (this.preventAction(event)) {
this.logger.log('info', 'keyboard', "[ActionHandler::handleKeyup] we are in a text box or something. Doing nothing.");
return;
}
this.execAction(this.keyUpActions, event);
this.execAction(this.keyUpActions, event);
} catch (e) {
this.logger.log('info', 'debug', '[ActionHandler::handleKeyup] Failed to handle keyup!', e);
}
}
handleKeydown(event) {
this.logger.log('info', 'keyboard', "%c[ActionHandler::handleKeydown] we pressed a key: ", "color: #ff0", event.key , " | keydown: ", event.keydown, "event:", event)
if (this.preventAction(event)) {
this.logger.log('info', 'keyboard', "[ActionHandler::handleKeydown] we are in a text box or something. Doing nothing.");
return;
}
try {
if (this.preventAction(event)) {
this.logger.log('info', 'keyboard', "[ActionHandler::handleKeydown] we are in a text box or something. Doing nothing.");
return;
}
this.execAction(this.keyDownActions, event);
this.execAction(this.keyDownActions, event);
} catch (e) {
this.logger.log('info', 'debug', '[ActionHandler::handleKeydown] Failed to handle keydown!', e);
}
}
handleMouseMove(event, videoData?: VideoData) {

View File

@ -91,6 +91,10 @@ class Logger {
constructor(options?: {vuexStore?: any, uwInstance?: any}) {
this.vuexStore = options?.vuexStore;
this.uwInstance = options?.uwInstance;
browser.storage.onChanged.addListener((changes, area) => {
this.storageChangeListener(changes, area)
});
}
static saveConfig(conf: LoggerConfig) {
@ -190,6 +194,34 @@ class Logger {
});
}
storageChangeListener(changes, area) {
if (!changes.uwLogger) {
console.info('We dont have any logging settings, not processing frther');
return;
}
try {
this.conf = JSON.parse(changes.uwLogger.newValue);
} catch (e) {
console.warn('[uwLogger] Error while trying to parse new conf for logger:', e, '\nWe received the following changes:', changes, 'for area:', area);
}
// This code can only execute if user tried to enable or disable logging
// through the popup. In cases like this, we do not gate the console.log
// behind a check, since we _always_ want to have this feedback in response
// to an action.
console.info(
'[uwLogger] logger config changed! New configuration:',
this.conf, '\nraw changes:', changes, 'area?', area,
'\n————————————————————————————————————————————————————————————————————————\n\n\n\n\n\n\n\n\n\n\n\n-----\nLogging with new settings starts now.'
);
// initiate loger if need be
if (!this.startTime) {
this.init(this.conf);
}
}
setVuexStore(store) {
this.vuexStore = store;
}
@ -386,7 +418,7 @@ class Logger {
}
canLogFile(component) {
if (!this.conf.fileOptions.enabled || this.temp_disable) {
if (!this.conf?.fileOptions?.enabled || this.temp_disable) {
return false;
}
if (Array.isArray(component) && component.length ) {