diff --git a/src/js/page/main-controller.js b/src/js/page/main-controller.js index b11d70b32..2c30462d3 100644 --- a/src/js/page/main-controller.js +++ b/src/js/page/main-controller.js @@ -250,12 +250,10 @@ export default class MainController { } async _loadSettings() { - let settings = await storage.get('settings'); - settings = Object.assign( - {}, - settings, - this._settingsUi.getSettingsOverride(), - ); + const settings = { + ...(await storage.get('settings')), + ...this._settingsUi.getSettingsOverride(), + }; if (settings) this._settingsUi.setSettings(settings); } diff --git a/src/js/page/ui/settings.js b/src/js/page/ui/settings.js index 530f39355..96e84d1c1 100644 --- a/src/js/page/ui/settings.js +++ b/src/js/page/ui/settings.js @@ -45,6 +45,9 @@ export default class Settings { if (event.target.closest('input[type=range]')) return; event.preventDefault(); }); + + const settingsOverride = this.getSettingsOverride(); + if (settingsOverride) this.setSettings(settingsOverride); }); } @@ -65,34 +68,23 @@ export default class Settings { _onReset() { this._resetRipple.animate(); const oldSettings = this.getSettings(); - const overrides = this.getSettingsOverride(); // Set all inputs according to their initial attributes for (const inputEl of this._globalInputs) { if (inputEl.type === 'checkbox') { - inputEl.checked = Object.prototype.hasOwnProperty.call( - overrides, - inputEl.name, - ) - ? overrides[inputEl.name] - : inputEl.hasAttribute('checked'); + inputEl.checked = inputEl.hasAttribute('checked'); } else if (inputEl.type === 'range') { - this._sliderMap.get(inputEl).value = - Object.prototype.hasOwnProperty.call(overrides, inputEl.name) - ? overrides[inputEl.name] - : inputEl.getAttribute('value'); + this._sliderMap.get(inputEl).value = inputEl.getAttribute('value'); } } for (const inputEl of this._pluginInputs) { - inputEl.checked = Object.prototype.hasOwnProperty.call( - overrides.plugins, - inputEl.name, - ) - ? overrides.plugins[inputEl.name] - : inputEl.hasAttribute('checked'); + inputEl.checked = inputEl.hasAttribute('checked'); } + const settingsOverride = this.getSettingsOverride(); + if (settingsOverride) this.setSettings(settingsOverride); + this.emitter.emit('reset', oldSettings); this.emitter.emit('change'); }