Переглянути джерело

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

master
Vlad Piersec 5 роки тому
джерело
коміт
b50d6e43d0

+ 39
- 0
react/features/base/devices/actions.js Переглянути файл

@@ -17,6 +17,7 @@ import {
17 17
 import {
18 18
     areDeviceLabelsInitialized,
19 19
     getDeviceIdByLabel,
20
+    getDeviceLabelById,
20 21
     getDevicesFromURL,
21 22
     setAudioOutputDeviceId
22 23
 } from './functions';
@@ -216,6 +217,25 @@ export function setAudioInputDevice(deviceId) {
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 240
  * Updates the output device id.
221 241
  *
@@ -244,6 +264,25 @@ export function setVideoInputDevice(deviceId) {
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 287
  * Signals to update the list of known audio and video devices.
249 288
  *

+ 2
- 2
react/features/settings/components/web/audio/AudioSettingsPopup.js Переглянути файл

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

+ 2
- 2
react/features/settings/components/web/video/VideoSettingsPopup.js Переглянути файл

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

Завантаження…
Відмінити
Зберегти