Browse Source

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

master
Vlad Piersec 5 years ago
parent
commit
b50d6e43d0

+ 39
- 0
react/features/base/devices/actions.js View File

17
 import {
17
 import {
18
     areDeviceLabelsInitialized,
18
     areDeviceLabelsInitialized,
19
     getDeviceIdByLabel,
19
     getDeviceIdByLabel,
20
+    getDeviceLabelById,
20
     getDevicesFromURL,
21
     getDevicesFromURL,
21
     setAudioOutputDeviceId
22
     setAudioOutputDeviceId
22
 } from './functions';
23
 } from './functions';
216
     };
217
     };
217
 }
218
 }
218
 
219
 
220
+/**
221
+ * Sets the audio input device id and updates the settings
222
+ * so they are persisted across sessions.
223
+ *
224
+ * @param {string} deviceId - The id of the new audio input device.
225
+ * @returns {Function}
226
+ */
227
+export function setAudioInputDeviceAndUpdateSettings(deviceId) {
228
+    return function(dispatch, getState) {
229
+        const deviceLabel = getDeviceLabelById(getState(), deviceId, 'audioInput');
230
+
231
+        dispatch(setAudioInputDevice(deviceId));
232
+        dispatch(updateSettings({
233
+            userSelectedMicDeviceId: deviceId,
234
+            userSelectedMicDeviceLabel: deviceLabel
235
+        }));
236
+    };
237
+}
238
+
219
 /**
239
 /**
220
  * Updates the output device id.
240
  * Updates the output device id.
221
  *
241
  *
244
     };
264
     };
245
 }
265
 }
246
 
266
 
267
+/**
268
+ * Sets the video input device id and updates the settings
269
+ * so they are persisted across sessions.
270
+ *
271
+ * @param {string} deviceId - The id of the new video input device.
272
+ * @returns {Function}
273
+ */
274
+export function setVideoInputDeviceAndUpdateSettings(deviceId) {
275
+    return function(dispatch, getState) {
276
+        const deviceLabel = getDeviceLabelById(getState(), deviceId, 'videoInput');
277
+
278
+        dispatch(setVideoInputDevice(deviceId));
279
+        dispatch(updateSettings({
280
+            userSelectedCameraDeviceId: deviceId,
281
+            userSelectedCameraDeviceLabel: deviceLabel
282
+        }));
283
+    };
284
+}
285
+
247
 /**
286
 /**
248
  * Signals to update the list of known audio and video devices.
287
  * Signals to update the list of known audio and video devices.
249
  *
288
  *

+ 2
- 2
react/features/settings/components/web/audio/AudioSettingsPopup.js View File

8
 import {
8
 import {
9
     getAudioInputDeviceData,
9
     getAudioInputDeviceData,
10
     getAudioOutputDeviceData,
10
     getAudioOutputDeviceData,
11
-    setAudioInputDevice as setAudioInputDeviceAction,
11
+    setAudioInputDeviceAndUpdateSettings,
12
     setAudioOutputDevice as setAudioOutputDeviceAction
12
     setAudioOutputDevice as setAudioOutputDeviceAction
13
 } from '../../../../base/devices';
13
 } from '../../../../base/devices';
14
 import { connect } from '../../../../base/redux';
14
 import { connect } from '../../../../base/redux';
90
 
90
 
91
 const mapDispatchToProps = {
91
 const mapDispatchToProps = {
92
     onClose: toggleAudioSettings,
92
     onClose: toggleAudioSettings,
93
-    setAudioInputDevice: setAudioInputDeviceAction,
93
+    setAudioInputDevice: setAudioInputDeviceAndUpdateSettings,
94
     setAudioOutputDevice: setAudioOutputDeviceAction
94
     setAudioOutputDevice: setAudioOutputDeviceAction
95
 };
95
 };
96
 
96
 

+ 2
- 2
react/features/settings/components/web/video/VideoSettingsPopup.js View File

6
 import { toggleVideoSettings } from '../../../actions';
6
 import { toggleVideoSettings } from '../../../actions';
7
 import {
7
 import {
8
     getVideoDeviceIds,
8
     getVideoDeviceIds,
9
-    setVideoInputDevice as setVideoInputDeviceAction
9
+    setVideoInputDeviceAndUpdateSettings
10
 } from '../../../../base/devices';
10
 } from '../../../../base/devices';
11
 import { getVideoSettingsVisibility } from '../../../functions';
11
 import { getVideoSettingsVisibility } from '../../../functions';
12
 import { connect } from '../../../../base/redux';
12
 import { connect } from '../../../../base/redux';
79
 
79
 
80
 const mapDispatchToProps = {
80
 const mapDispatchToProps = {
81
     onClose: toggleVideoSettings,
81
     onClose: toggleVideoSettings,
82
-    setVideoInputDevice: setVideoInputDeviceAction
82
+    setVideoInputDevice: setVideoInputDeviceAndUpdateSettings
83
 };
83
 };
84
 
84
 
85
 export default connect(mapStateToProps, mapDispatchToProps)(VideoSettingsPopup);
85
 export default connect(mapStateToProps, mapDispatchToProps)(VideoSettingsPopup);

Loading…
Cancel
Save