diff --git a/react/features/base/devices/actions.js b/react/features/base/devices/actions.js index e5e3dd175..b5fc88573 100644 --- a/react/features/base/devices/actions.js +++ b/react/features/base/devices/actions.js @@ -17,6 +17,7 @@ import { import { areDeviceLabelsInitialized, getDeviceIdByLabel, + getDeviceLabelById, getDevicesFromURL, setAudioOutputDeviceId } from './functions'; @@ -216,6 +217,25 @@ export function setAudioInputDevice(deviceId) { }; } +/** + * Sets the audio input device id and updates the settings + * so they are persisted across sessions. + * + * @param {string} deviceId - The id of the new audio input device. + * @returns {Function} + */ +export function setAudioInputDeviceAndUpdateSettings(deviceId) { + return function(dispatch, getState) { + const deviceLabel = getDeviceLabelById(getState(), deviceId, 'audioInput'); + + dispatch(setAudioInputDevice(deviceId)); + dispatch(updateSettings({ + userSelectedMicDeviceId: deviceId, + userSelectedMicDeviceLabel: deviceLabel + })); + }; +} + /** * Updates the output device id. * @@ -244,6 +264,25 @@ export function setVideoInputDevice(deviceId) { }; } +/** + * Sets the video input device id and updates the settings + * so they are persisted across sessions. + * + * @param {string} deviceId - The id of the new video input device. + * @returns {Function} + */ +export function setVideoInputDeviceAndUpdateSettings(deviceId) { + return function(dispatch, getState) { + const deviceLabel = getDeviceLabelById(getState(), deviceId, 'videoInput'); + + dispatch(setVideoInputDevice(deviceId)); + dispatch(updateSettings({ + userSelectedCameraDeviceId: deviceId, + userSelectedCameraDeviceLabel: deviceLabel + })); + }; +} + /** * Signals to update the list of known audio and video devices. * diff --git a/react/features/settings/components/web/audio/AudioSettingsPopup.js b/react/features/settings/components/web/audio/AudioSettingsPopup.js index 4a7803602..af15a8660 100644 --- a/react/features/settings/components/web/audio/AudioSettingsPopup.js +++ b/react/features/settings/components/web/audio/AudioSettingsPopup.js @@ -8,7 +8,7 @@ import { toggleAudioSettings } from '../../../actions'; import { getAudioInputDeviceData, getAudioOutputDeviceData, - setAudioInputDevice as setAudioInputDeviceAction, + setAudioInputDeviceAndUpdateSettings, setAudioOutputDevice as setAudioOutputDeviceAction } from '../../../../base/devices'; import { connect } from '../../../../base/redux'; @@ -90,7 +90,7 @@ function mapStateToProps(state) { const mapDispatchToProps = { onClose: toggleAudioSettings, - setAudioInputDevice: setAudioInputDeviceAction, + setAudioInputDevice: setAudioInputDeviceAndUpdateSettings, setAudioOutputDevice: setAudioOutputDeviceAction }; diff --git a/react/features/settings/components/web/video/VideoSettingsPopup.js b/react/features/settings/components/web/video/VideoSettingsPopup.js index a2bac8968..b891f6a53 100644 --- a/react/features/settings/components/web/video/VideoSettingsPopup.js +++ b/react/features/settings/components/web/video/VideoSettingsPopup.js @@ -6,7 +6,7 @@ import InlineDialog from '@atlaskit/inline-dialog'; import { toggleVideoSettings } from '../../../actions'; import { getVideoDeviceIds, - setVideoInputDevice as setVideoInputDeviceAction + setVideoInputDeviceAndUpdateSettings } from '../../../../base/devices'; import { getVideoSettingsVisibility } from '../../../functions'; import { connect } from '../../../../base/redux'; @@ -79,7 +79,7 @@ function mapStateToProps(state) { const mapDispatchToProps = { onClose: toggleVideoSettings, - setVideoInputDevice: setVideoInputDeviceAction + setVideoInputDevice: setVideoInputDeviceAndUpdateSettings }; export default connect(mapStateToProps, mapDispatchToProps)(VideoSettingsPopup);