Browse Source

fix(iframe-api): setDevice.

j8
Hristo Terezov 4 years ago
parent
commit
b7529863d5

+ 9
- 4
react/features/base/devices/middleware.js View File

@@ -5,7 +5,6 @@ import { processExternalDeviceRequest } from '../../device-selection';
5 5
 import { showNotification, showWarningNotification } from '../../notifications';
6 6
 import { replaceAudioTrackById, replaceVideoTrackById, setDeviceStatusWarning } from '../../prejoin/actions';
7 7
 import { isPrejoinPageVisible } from '../../prejoin/functions';
8
-import { CONFERENCE_JOINED } from '../conference';
9 8
 import { JitsiTrackErrors } from '../lib-jitsi-meet';
10 9
 import { MiddlewareRegistry } from '../redux';
11 10
 import { updateSettings } from '../settings';
@@ -24,6 +23,7 @@ import {
24 23
     setVideoInputDevice
25 24
 } from './actions';
26 25
 import {
26
+    areDeviceLabelsInitialized,
27 27
     formatDeviceLabel,
28 28
     groupDevicesByKind,
29 29
     setAudioOutputDeviceId
@@ -73,8 +73,6 @@ function logDeviceList(deviceList) {
73 73
 // eslint-disable-next-line no-unused-vars
74 74
 MiddlewareRegistry.register(store => next => action => {
75 75
     switch (action.type) {
76
-    case CONFERENCE_JOINED:
77
-        return _conferenceJoined(store, next, action);
78 76
     case NOTIFY_CAMERA_ERROR: {
79 77
         if (typeof APP !== 'object' || !action.error) {
80 78
             break;
@@ -148,6 +146,9 @@ MiddlewareRegistry.register(store => next => action => {
148 146
         break;
149 147
     case UPDATE_DEVICE_LIST:
150 148
         logDeviceList(groupDevicesByKind(action.devices));
149
+        if (areDeviceLabelsInitialized(store.getState())) {
150
+            return _processPendingRequests(store, next, action);
151
+        }
151 152
         break;
152 153
     case CHECK_AND_NOTIFY_FOR_NEW_DEVICE:
153 154
         _checkAndNotifyForNewDevice(store, action.newDevices, action.oldDevices);
@@ -170,11 +171,15 @@ MiddlewareRegistry.register(store => next => action => {
170 171
  * @private
171 172
  * @returns {Object} The value returned by {@code next(action)}.
172 173
  */
173
-function _conferenceJoined({ dispatch, getState }, next, action) {
174
+function _processPendingRequests({ dispatch, getState }, next, action) {
174 175
     const result = next(action);
175 176
     const state = getState();
176 177
     const { pendingRequests } = state['features/base/devices'];
177 178
 
179
+    if (!pendingRequests || pendingRequests.length === 0) {
180
+        return result;
181
+    }
182
+
178 183
     pendingRequests.forEach(request => {
179 184
         processExternalDeviceRequest(
180 185
             dispatch,

+ 1
- 2
react/features/device-selection/functions.js View File

@@ -86,7 +86,6 @@ export function processExternalDeviceRequest( // eslint-disable-line max-params
86 86
     }
87 87
     const state = getState();
88 88
     const settings = state['features/base/settings'];
89
-    const { conference } = state['features/base/conference'];
90 89
     let result = true;
91 90
 
92 91
     switch (request.name) {
@@ -165,7 +164,7 @@ export function processExternalDeviceRequest( // eslint-disable-line max-params
165 164
     case 'setDevice': {
166 165
         const { device } = request;
167 166
 
168
-        if (!conference) {
167
+        if (!areDeviceLabelsInitialized(state)) {
169 168
             dispatch(addPendingDeviceRequest({
170 169
                 type: 'devices',
171 170
                 name: 'setDevice',

Loading…
Cancel
Save