From 94620f4f224ffec20b774dd75143ce5023c60b83 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 31 Oct 2020 17:13:24 -0400 Subject: [PATCH] Trigger event on property change (#979) * Add _triggerScanInputsChanged function * Trigger event when inputs are changed --- ext/bg/js/settings/scan-inputs-controller.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ext/bg/js/settings/scan-inputs-controller.js b/ext/bg/js/settings/scan-inputs-controller.js index fbafe570..3ee4cb34 100644 --- a/ext/bg/js/settings/scan-inputs-controller.js +++ b/ext/bg/js/settings/scan-inputs-controller.js @@ -64,9 +64,12 @@ class ScanInputsController { return true; } - setProperty(index, property, value) { + async setProperty(index, property, value, event) { const path = `scanning.inputs[${index}].${property}`; - return this._settingsController.setProfileSetting(path, value); + await this._settingsController.setProfileSetting(path, value); + if (event) { + this._triggerScanInputsChanged(); + } } instantiateTemplate(name) { @@ -131,6 +134,10 @@ class ScanInputsController { async _modifyProfileSettings(targets) { await this._settingsController.modifyProfileSettings(targets); + this._triggerScanInputsChanged(); + } + + _triggerScanInputsChanged() { this._settingsController.trigger('scanInputsChanged', {source: this}); } @@ -224,11 +231,11 @@ class ScanInputField { // Private _onIncludeValueChange({value}) { - this._parent.setProperty(this._index, 'include', value); + this._parent.setProperty(this._index, 'include', value, true); } _onExcludeValueChange({value}) { - this._parent.setProperty(this._index, 'exclude', value); + this._parent.setProperty(this._index, 'exclude', value, true); } _onRemoveClick(e) { @@ -287,6 +294,6 @@ class ScanInputField { _setAdvancedOptionsVisible(showAdvanced) { showAdvanced = !!showAdvanced; this._node.dataset.showAdvanced = `${showAdvanced}`; - this._parent.setProperty(this._index, 'options.showAdvanced', showAdvanced); + this._parent.setProperty(this._index, 'options.showAdvanced', showAdvanced, false); } }