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: store.getState() called while the reducer is executing

paweldomas1ff27b7298ac
diff --git a/react/features/base/devices/middleware.js b/react/features/base/devices/middleware.js
index 5884695dea..99fae99f3f 100644
--- a/react/features/base/devices/middleware.js
+++ b/react/features/base/devices/middleware.js
@@ -15,14 +15,19 @@ import {
NOTIFY_CAMERA_ERROR,
NOTIFY_MIC_ERROR,
SET_AUDIO_INPUT_DEVICE,
- SET_VIDEO_INPUT_DEVICE
+ SET_VIDEO_INPUT_DEVICE,
+ UPDATE_DEVICE_LIST
} from './actionTypes';
import {
removePendingDeviceRequests,
setAudioInputDevice,
setVideoInputDevice
} from './actions';
-import { formatDeviceLabel, setAudioOutputDeviceId } from './functions';
+import {
+ formatDeviceLabel,
+ groupDevicesByKind,
+ setAudioOutputDeviceId
+} from './functions';
import logger from './logger';
const JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP = {
@@ -41,6 +46,24 @@ const JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP = {
}
};
+/**
+ * Logs the current device list.
+ *
+ * @param {Object} deviceList - Whatever is returned by {@link groupDevicesByKind}.
+ * @returns {string}
+ */
+function logDeviceList(deviceList) {
+ const devicesToStr = list => list.map(device => `\t\t${device.label}[${device.deviceId}]`).join('\n');
+ const audioInputs = devicesToStr(deviceList.audioInput);
+ const audioOutputs = devicesToStr(deviceList.audioOutput);
+ const videoInputs = devicesToStr(deviceList.videoInput);
+
+ logger.debug('Device list updated:\n'
+ + `audioInput:\n${audioInputs}\n`
+ + `audioOutput:\n${audioOutputs}\n`
+ + `videoInput:\n${videoInputs}`);
+}
+
/**
* Implements the middleware of the feature base/devices.
*
@@ -123,6 +146,9 @@ MiddlewareRegistry.register(store => next => action => {
APP.UI.emitEvent(UIEvents.VIDEO_DEVICE_CHANGED, action.deviceId);
}
break;
+ case UPDATE_DEVICE_LIST:
+ logDeviceList(groupDevicesByKind(action.devices));
+ break;
case CHECK_AND_NOTIFY_FOR_NEW_DEVICE:
_checkAndNotifyForNewDevice(store, action.newDevices, action.oldDevices);
break;
diff --git a/react/features/base/devices/reducer.js b/react/features/base/devices/reducer.js
index 206b5e416e..1a53c05387 100644
--- a/react/features/base/devices/reducer.js
+++ b/react/features/base/devices/reducer.js
@@ -19,24 +19,6 @@ const DEFAULT_STATE = {
pendingRequests: []
};
-/**
- * Logs the current device list.
- *
- * @param {Object} deviceList - Whatever is returned by {@link groupDevicesByKind}.
- * @returns {string}
- */
-function logDeviceList(deviceList) {
- const devicesToStr = list => list.map(device => `\t\t${device.label}[${device.deviceId}]`).join('\n');
- const audioInputs = devicesToStr(deviceList.audioInput);
- const audioOutputs = devicesToStr(deviceList.audioOutput);
- const videoInputs = devicesToStr(deviceList.videoInput);
-
- logger.debug('Device list updated:\n'
- + `audioInput:\n${audioInputs}\n`
- + `audioOutput:\n${audioOutputs}\n`
- + `videoInput:\n${videoInputs}`);
-}
-
/**
* Listen for actions which changes the state of known and used devices.
*
@@ -54,8 +36,6 @@ ReducerRegistry.register(
case UPDATE_DEVICE_LIST: {
const deviceList = groupDevicesByKind(action.devices);
- logDeviceList(deviceList);
-
return {
...state,
availableDevices: deviceList