Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Consistent formatting

Lyubo Marinov7f041170f725
diff --git a/conference.js b/conference.js
index 20e5d10beb..43a92d82ad 100644
--- a/conference.js
+++ b/conference.js
@@ -29,15 +29,11 @@ import {
EMAIL_COMMAND,
lockStateChanged
} from './react/features/base/conference';
-import {
- updateDeviceList
-} from './react/features/base/devices';
+import { updateDeviceList } from './react/features/base/devices';
import {
isFatalJitsiConnectionError
} from './react/features/base/lib-jitsi-meet';
-import {
- setVideoAvailable
-} from './react/features/base/media';
+import { setVideoAvailable } from './react/features/base/media';
import {
localParticipantRoleChanged,
MAX_DISPLAY_NAME_LENGTH,
@@ -51,9 +47,7 @@ import {
trackAdded,
trackRemoved
} from './react/features/base/tracks';
-import {
- showDesktopPicker
-} from './react/features/desktop-picker';
+import { showDesktopPicker } from './react/features/desktop-picker';
import {
mediaPermissionPromptVisibilityChanged,
suspendDetected
diff --git a/react/features/base/media/actionTypes.js b/react/features/base/media/actionTypes.js
index da9d5c8200..4c233082a9 100644
--- a/react/features/base/media/actionTypes.js
+++ b/react/features/base/media/actionTypes.js
@@ -24,7 +24,7 @@ export const SET_CAMERA_FACING_MODE = Symbol('SET_CAMERA_FACING_MODE');
*
* {
* type: SET_VIDEO_AVAILABLE,
- * muted: boolean
+ * available: boolean
* }
*/
export const SET_VIDEO_AVAILABLE = Symbol('SET_VIDEO_AVAILABLE');
diff --git a/react/features/base/media/actions.js b/react/features/base/media/actions.js
index 81ebb20c6b..c15d23f217 100644
--- a/react/features/base/media/actions.js
+++ b/react/features/base/media/actions.js
@@ -17,9 +17,9 @@ import { CAMERA_FACING_MODE } from './constants';
* @param {boolean} muted - True if the local audio is to be muted or false if
* the local audio is to be unmuted.
* @returns {{
- * type: SET_AUDIO_MUTED,
- * muted: boolean
- * }}
+ * type: SET_AUDIO_MUTED,
+ * muted: boolean
+ * }}
*/
export function setAudioMuted(muted: boolean) {
return {
@@ -33,9 +33,9 @@ export function setAudioMuted(muted: boolean) {
*
* @param {CAMERA_FACING_MODE} cameraFacingMode - The camera facing mode to set.
* @returns {{
- * type: SET_CAMERA_FACING_MODE,
- * cameraFacingMode: CAMERA_FACING_MODE
- * }}
+ * type: SET_CAMERA_FACING_MODE,
+ * cameraFacingMode: CAMERA_FACING_MODE
+ * }}
*/
export function setCameraFacingMode(cameraFacingMode: CAMERA_FACING_MODE) {
return {
@@ -50,9 +50,9 @@ export function setCameraFacingMode(cameraFacingMode: CAMERA_FACING_MODE) {
* @param {boolean} available - True if the local video is to be marked as
* available or false if the local video is not available.
* @returns {{
- * type: SET_VIDEO_AVAILABLE,
- * available: boolean
- * }}
+ * type: SET_VIDEO_AVAILABLE,
+ * available: boolean
+ * }}
*/
export function setVideoAvailable(available: boolean) {
return {
@@ -67,9 +67,9 @@ export function setVideoAvailable(available: boolean) {
* @param {boolean} muted - True if the local video is to be muted or false if
* the local video is to be unmuted.
* @returns {{
- * type: SET_VIDEO_MUTED,
- * muted: boolean
- * }}
+ * type: SET_VIDEO_MUTED,
+ * muted: boolean
+ * }}
*/
export function setVideoMuted(muted: boolean) {
return {
diff --git a/react/features/base/media/reducer.js b/react/features/base/media/reducer.js
index 0fe96f2c8d..d8ce8fc5b4 100644
--- a/react/features/base/media/reducer.js
+++ b/react/features/base/media/reducer.js
@@ -5,8 +5,8 @@ import { ReducerRegistry } from '../redux';
import {
SET_AUDIO_MUTED,
SET_CAMERA_FACING_MODE,
- SET_VIDEO_MUTED,
SET_VIDEO_AVAILABLE,
+ SET_VIDEO_MUTED,
TOGGLE_CAMERA_FACING_MODE
} from './actionTypes';
import { CAMERA_FACING_MODE } from './constants';
@@ -79,16 +79,16 @@ const VIDEO_INITIAL_MEDIA_STATE = {
*/
function _video(state = VIDEO_INITIAL_MEDIA_STATE, action) {
switch (action.type) {
- case SET_VIDEO_AVAILABLE:
+ case SET_CAMERA_FACING_MODE:
return {
...state,
- available: action.available
+ facingMode: action.cameraFacingMode
};
- case SET_CAMERA_FACING_MODE:
+ case SET_VIDEO_AVAILABLE:
return {
...state,
- facingMode: action.cameraFacingMode
+ available: action.available
};
case SET_VIDEO_MUTED:
diff --git a/react/features/toolbox/middleware.js b/react/features/toolbox/middleware.js
index c7050bfd8a..c01cb7a55d 100644
--- a/react/features/toolbox/middleware.js
+++ b/react/features/toolbox/middleware.js
@@ -1,59 +1,16 @@
/* @flow */
+import { SET_VIDEO_AVAILABLE, SET_VIDEO_MUTED } from '../base/media';
import { MiddlewareRegistry } from '../base/redux';
-import {
- CLEAR_TOOLBOX_TIMEOUT,
- SET_TOOLBOX_TIMEOUT
-} from './actionTypes';
-
-import {
- SET_VIDEO_AVAILABLE,
- SET_VIDEO_MUTED
-} from '../../features/base/media/actionTypes';
-
-import {
- setToolbarButton
-} from './actions';
-
-/**
- * Adjusts the state of toolbar's camera button.
- *
- * @param {Store} store - The Redux store instance.
- * @param {Object} action - Either SET_VIDEO_AVAILABLE or SET_VIDEO_MUTED.
- *
- * @returns {*}
- */
-function setCameraButton(store, action) {
- const video = store.getState()['features/base/media'].video;
- let available = video.available;
-
- if (typeof action.available === 'boolean') {
- available = action.available;
- }
-
- let muted = video.muted;
-
- if (typeof action.muted === 'boolean') {
- muted = action.muted;
- }
-
- const i18nKey = available ? 'videomute' : 'cameraDisabled';
- const i18n = `[content]toolbar.${i18nKey}`;
- const button = {
- enabled: available,
- i18n,
- toggled: available ? muted : true
- };
-
- store.dispatch(setToolbarButton('camera', button));
-}
+import { setToolbarButton } from './actions';
+import { CLEAR_TOOLBOX_TIMEOUT, SET_TOOLBOX_TIMEOUT } from './actionTypes';
/**
* Middleware which intercepts Toolbox actions to handle changes to the
* visibility timeout of the Toolbox.
*
- * @param {Store} store - Redux store.
+ * @param {Store} store - The redux store.
* @returns {Function}
*/
MiddlewareRegistry.register(store => next => action => {
@@ -77,13 +34,35 @@ MiddlewareRegistry.register(store => next => action => {
}
case SET_VIDEO_AVAILABLE:
- case SET_VIDEO_MUTED: {
- setCameraButton(store, action);
- break;
- }
-
-
+ case SET_VIDEO_MUTED:
+ return _setVideoAvailableOrMuted(store, next, action);
}
return next(action);
});
+
+/**
+ * Adjusts the state of toolbar's camera button.
+ *
+ * @param {Store} store - The redux store.
+ * @param {Function} next - The redux function to continue dispatching the
+ * specified {@code action} in the specified {@code store}.
+ * @param {Object} action - Either {@link SET_VIDEO_AVAILABLE} or
+ * {@link SET_VIDEO_MUTED}.
+ * @returns {Object} The new state that is the result of the reduction of the
+ * specified {@code action}.
+ */
+function _setVideoAvailableOrMuted({ dispatch, getState }, next, action) {
+ const result = next(action);
+
+ const { available, muted } = getState()['features/base/media'].video;
+ const i18nKey = available ? 'videomute' : 'cameraDisabled';
+
+ dispatch(setToolbarButton('camera', {
+ enabled: available,
+ i18n: `[content]toolbar.${i18nKey}`,
+ toggled: available ? muted : true
+ }));
+
+ return result;
+}