Settings should only watch for uwSettings storage changes, Logger should only monitor for uwLogger changes

This commit is contained in:
Tamius Han 2020-01-29 01:36:09 +01:00
parent 9ba1afebee
commit 1899f486e1
2 changed files with 8 additions and 1 deletions

View File

@ -16,7 +16,11 @@ class Logger {
static syncConfig(callback) { static syncConfig(callback) {
const br = currentBrowser.firefox ? browser : chrome; const br = currentBrowser.firefox ? browser : chrome;
br.storage.onChanged.addListener( (changes, area) => { br.storage.onChanged.addListener( (changes, area) => {
callback(JSON.parse(changes.uwLogger.newValue)); if (changes.uwLogger) {
const newLoggerConf = JSON.parse(changes.uwLogger.newValue)
console.info('Logger settings reloaded. New conf:', conf);
callback(newLoggerConf);
}
}); });
} }

View File

@ -35,6 +35,9 @@ class Settings {
} }
storageChangeListener(changes, area) { storageChangeListener(changes, area) {
if (!changes.uwSettings) {
return;
}
this.logger.log('info', 'settings', "[Settings::<storage/on change>] Settings have been changed outside of here. Updating active settings. Changes:", changes, "storage area:", area); this.logger.log('info', 'settings', "[Settings::<storage/on change>] Settings have been changed outside of here. Updating active settings. Changes:", changes, "storage area:", area);
if (changes['uwSettings'] && changes['uwSettings'].newValue) { if (changes['uwSettings'] && changes['uwSettings'].newValue) {
this.logger.log('info', 'settings',"[Settings::<storage/on change>] new settings object:", JSON.parse(changes.uwSettings.newValue)); this.logger.log('info', 'settings',"[Settings::<storage/on change>] new settings object:", JSON.parse(changes.uwSettings.newValue));