fix(iframe-api): setDevice.

This commit is contained in:
Hristo Terezov 2020-08-25 17:31:38 -05:00
parent 4ded94d130
commit b7529863d5
2 changed files with 10 additions and 6 deletions

View File

@ -5,7 +5,6 @@ import { processExternalDeviceRequest } from '../../device-selection';
import { showNotification, showWarningNotification } from '../../notifications'; import { showNotification, showWarningNotification } from '../../notifications';
import { replaceAudioTrackById, replaceVideoTrackById, setDeviceStatusWarning } from '../../prejoin/actions'; import { replaceAudioTrackById, replaceVideoTrackById, setDeviceStatusWarning } from '../../prejoin/actions';
import { isPrejoinPageVisible } from '../../prejoin/functions'; import { isPrejoinPageVisible } from '../../prejoin/functions';
import { CONFERENCE_JOINED } from '../conference';
import { JitsiTrackErrors } from '../lib-jitsi-meet'; import { JitsiTrackErrors } from '../lib-jitsi-meet';
import { MiddlewareRegistry } from '../redux'; import { MiddlewareRegistry } from '../redux';
import { updateSettings } from '../settings'; import { updateSettings } from '../settings';
@ -24,6 +23,7 @@ import {
setVideoInputDevice setVideoInputDevice
} from './actions'; } from './actions';
import { import {
areDeviceLabelsInitialized,
formatDeviceLabel, formatDeviceLabel,
groupDevicesByKind, groupDevicesByKind,
setAudioOutputDeviceId setAudioOutputDeviceId
@ -73,8 +73,6 @@ function logDeviceList(deviceList) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
MiddlewareRegistry.register(store => next => action => { MiddlewareRegistry.register(store => next => action => {
switch (action.type) { switch (action.type) {
case CONFERENCE_JOINED:
return _conferenceJoined(store, next, action);
case NOTIFY_CAMERA_ERROR: { case NOTIFY_CAMERA_ERROR: {
if (typeof APP !== 'object' || !action.error) { if (typeof APP !== 'object' || !action.error) {
break; break;
@ -148,6 +146,9 @@ MiddlewareRegistry.register(store => next => action => {
break; break;
case UPDATE_DEVICE_LIST: case UPDATE_DEVICE_LIST:
logDeviceList(groupDevicesByKind(action.devices)); logDeviceList(groupDevicesByKind(action.devices));
if (areDeviceLabelsInitialized(store.getState())) {
return _processPendingRequests(store, next, action);
}
break; break;
case CHECK_AND_NOTIFY_FOR_NEW_DEVICE: case CHECK_AND_NOTIFY_FOR_NEW_DEVICE:
_checkAndNotifyForNewDevice(store, action.newDevices, action.oldDevices); _checkAndNotifyForNewDevice(store, action.newDevices, action.oldDevices);
@ -170,11 +171,15 @@ MiddlewareRegistry.register(store => next => action => {
* @private * @private
* @returns {Object} The value returned by {@code next(action)}. * @returns {Object} The value returned by {@code next(action)}.
*/ */
function _conferenceJoined({ dispatch, getState }, next, action) { function _processPendingRequests({ dispatch, getState }, next, action) {
const result = next(action); const result = next(action);
const state = getState(); const state = getState();
const { pendingRequests } = state['features/base/devices']; const { pendingRequests } = state['features/base/devices'];
if (!pendingRequests || pendingRequests.length === 0) {
return result;
}
pendingRequests.forEach(request => { pendingRequests.forEach(request => {
processExternalDeviceRequest( processExternalDeviceRequest(
dispatch, dispatch,

View File

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