diff --git a/src/csui/LoggerUi.vue b/src/csui/LoggerUi.vue index b56c3ca..debd257 100644 --- a/src/csui/LoggerUi.vue +++ b/src/csui/LoggerUi.vue @@ -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}); diff --git a/src/ext/lib/ActionHandler.ts b/src/ext/lib/ActionHandler.ts index e2a0e08..4f09458 100644 --- a/src/ext/lib/ActionHandler.ts +++ b/src/ext/lib/ActionHandler.ts @@ -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) { diff --git a/src/ext/lib/Logger.ts b/src/ext/lib/Logger.ts index 3631ec0..e977892 100644 --- a/src/ext/lib/Logger.ts +++ b/src/ext/lib/Logger.ts @@ -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 ) {