aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-10-18 13:18:57 -0400
committerGitHub <noreply@github.com>2020-10-18 13:18:57 -0400
commit988ea8f70af3c93338b041e7148de7b7623100d0 (patch)
tree7af967dae7ee09cd47d665fc004608dd46f8ef73 /ext
parent3ab63f4f55052c215aa7bcf6352cdb4205252f5d (diff)
Update audio controller for menus (#936)
* Make event non-async * Only add event listener if the button exists * Add support for menu for removal
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/settings/audio-controller.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/ext/bg/js/settings/audio-controller.js b/ext/bg/js/settings/audio-controller.js
index ae0e234a..9a44e870 100644
--- a/ext/bg/js/settings/audio-controller.js
+++ b/ext/bg/js/settings/audio-controller.js
@@ -155,6 +155,7 @@ class AudioController {
const container = this._settingsController.instantiateTemplate('audio-source');
const select = container.querySelector('.audio-source-select');
const removeButton = container.querySelector('.audio-source-remove');
+ const menuButton = container.querySelector('.audio-source-menu-button');
select.value = value;
@@ -165,7 +166,12 @@ class AudioController {
};
eventListeners.addEventListener(select, 'change', this._onAudioSourceSelectChange.bind(this, entry), false);
- eventListeners.addEventListener(removeButton, 'click', this._onAudioSourceRemoveClicked.bind(this, entry), false);
+ if (removeButton !== null) {
+ eventListeners.addEventListener(removeButton, 'click', this._onAudioSourceRemoveClicked.bind(this, entry), false);
+ }
+ if (menuButton !== null) {
+ eventListeners.addEventListener(menuButton, 'menuClosed', this._onMenuClosed.bind(this, entry), false);
+ }
this._audioSourceContainer.appendChild(container);
this._audioSourceEntries.push(entry);
@@ -216,7 +222,16 @@ class AudioController {
await this._settingsController.setProfileSetting(`audio.sources[${index}]`, value);
}
- async _onAudioSourceRemoveClicked(entry) {
- await this._removeAudioSourceEntry(entry);
+ _onAudioSourceRemoveClicked(entry) {
+ this._removeAudioSourceEntry(entry);
+ }
+
+ _onMenuClosed(entry, e) {
+ const {detail: {action}} = e;
+ switch (action) {
+ case 'remove':
+ this._removeAudioSourceEntry(entry);
+ break;
+ }
}
}