diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2021-08-31 15:18:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-31 15:18:13 +0200 |
commit | 54d8059cc5945f6a1ef1b200481472ee684c4964 (patch) | |
tree | ffa84d1498bbc5bc26a7f031d10de8c6486a9913 | |
parent | 7df94d8d986ca8f8fc1366d1ef9edece5f37a418 (diff) | |
parent | 91d163bd29caabaa01a97d821d640a2a35123aa2 (diff) |
Merge pull request #6160 from nextcloud/bugfix/noid/dont-overwrite-selected-devices-when-there-is-only-one
Don't save device selection when there is only one device
-rw-r--r-- | src/components/MediaDevicesSelector.vue | 21 | ||||
-rw-r--r-- | src/utils/webrtc/MediaDevicesManager.js | 2 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/components/MediaDevicesSelector.vue b/src/components/MediaDevicesSelector.vue index 096d85670..d9ffa8a0b 100644 --- a/src/components/MediaDevicesSelector.vue +++ b/src/components/MediaDevicesSelector.vue @@ -155,7 +155,26 @@ export default { // The watcher should not be set as "immediate" to prevent // "update:deviceId" from being emitted when mounted with the same value // initially passed to the component. - deviceSelectedOption(deviceSelectedOption) { + deviceSelectedOption(deviceSelectedOption, previousSelectedOption) { + // The deviceSelectedOption may be the same as before yet a change + // could be triggered if media permissions are granted, which would + // update the label. + if (deviceSelectedOption && previousSelectedOption && deviceSelectedOption.id === previousSelectedOption.id) { + return + } + + // The previous selected option changed due to the device being + // disconnected, so ignore it as it was not explicitly changed by + // the user. + if (previousSelectedOption && previousSelectedOption.id && !this.deviceOptions.find(option => option.id === previousSelectedOption.id)) { + return + } + + // Ignore device change on initial loading of the settings dialog. + if (typeof previousSelectedOption?.id === 'undefined') { + return + } + if (deviceSelectedOption && deviceSelectedOption.id === null) { this.$emit('update:deviceId', null) return diff --git a/src/utils/webrtc/MediaDevicesManager.js b/src/utils/webrtc/MediaDevicesManager.js index e9d6b8a13..b43956247 100644 --- a/src/utils/webrtc/MediaDevicesManager.js +++ b/src/utils/webrtc/MediaDevicesManager.js @@ -115,6 +115,8 @@ MediaDevicesManager.prototype = { this._trigger('change:' + key, [value]) this._storeDeviceId(key, value) + + console.debug('Storing device selection in the browser storage: ', key, value) }, _storeDeviceId(key, value) { |