diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-01-14 22:01:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-14 22:01:01 -0500 |
commit | d9f5d21d15a8239ecf349d254606be2c8fa70d31 (patch) | |
tree | e9237cc284bf841a32903bc0bc721e83c7efa7bc /ext/bg/js/settings/profile-controller.js | |
parent | 29b6c98e9fa31e2397986bf0750f4b696a0051d5 (diff) |
Fix profile conditions issues (#1239)
* Add an event for when the number of profile conditions changes
* Update count
* Fix stale data being used
* Add "Remove group" option
Diffstat (limited to 'ext/bg/js/settings/profile-controller.js')
-rw-r--r-- | ext/bg/js/settings/profile-controller.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/ext/bg/js/settings/profile-controller.js b/ext/bg/js/settings/profile-controller.js index b56f92bb..f40818c7 100644 --- a/ext/bg/js/settings/profile-controller.js +++ b/ext/bg/js/settings/profile-controller.js @@ -92,6 +92,7 @@ class ProfileController { if (this._profileMoveUpButton !== null) { this._profileMoveUpButton.addEventListener('click', this._onMove.bind(this, -1), false); } if (this._profileMoveDownButton !== null) { this._profileMoveDownButton.addEventListener('click', this._onMove.bind(this, 1), false); } + this._profileConditionsUI.on('conditionGroupCountChanged', this._onConditionGroupCountChanged.bind(this)); this._settingsController.on('optionsChanged', this._onOptionsChanged.bind(this)); this._onOptionsChanged(); } @@ -334,7 +335,7 @@ class ProfileController { this._profileConditionsUI.cleanup(); this._profileConditionsIndex = profileIndex; - this._profileConditionsUI.prepare(profileIndex, profile.conditionGroups); + this._profileConditionsUI.prepare(profileIndex); if (this._profileConditionsProfileName !== null) { this._profileConditionsProfileName.textContent = profile.name; } @@ -368,7 +369,7 @@ class ProfileController { this._profileConditionsUI.cleanup(); const conditionsProfile = this._getProfile(this._profileConditionsIndex !== null ? this._profileConditionsIndex : settingsProfileIndex); if (conditionsProfile !== null) { - this._profileConditionsUI.prepare(settingsProfileIndex, conditionsProfile.conditionGroups); + this._profileConditionsUI.prepare(settingsProfileIndex); } // Udpate profile entries @@ -449,6 +450,13 @@ class ProfileController { this.moveProfile(this._settingsController.profileIndex, offset); } + _onConditionGroupCountChanged({count, profileIndex}) { + if (profileIndex >= 0 && profileIndex < this._profileEntryList.length) { + const profileEntry = this._profileEntryList[profileIndex]; + profileEntry.setConditionGroupsCount(count); + } + } + _addProfileEntry(profileIndex) { const profile = this._profiles[profileIndex]; const node = this._settingsController.instantiateTemplate('profile-entry'); @@ -626,10 +634,14 @@ class ProfileEntry { updateState() { this._nameInput.value = this._profile.name; - this._countText.textContent = this._profile.conditionGroups.length; + this._countText.textContent = `${this._profile.conditionGroups.length}`; this._isDefaultRadio.checked = (this._index === this._profileController.profileCurrentIndex); } + setConditionGroupsCount(count) { + this._countText.textContent = `${count}`; + } + // Private _onIsDefaultRadioChange(e) { |