Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(settings_buttons): Persist audio/video settings across sessions.

Vlad Piersecb50d6e43d016
diff --git a/react/features/base/devices/actions.js b/react/features/base/devices/actions.js
index e5e3dd175c..b5fc88573e 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 4a7803602f..af15a86608 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 a2bac89686..b891f6a535 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);