Consistent formatting

This commit is contained in:
Lyubo Marinov 2017-07-16 03:44:07 -05:00
parent e54744e5ef
commit 7f041170f7
5 changed files with 55 additions and 82 deletions

View File

@ -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

View File

@ -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');

View File

@ -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 {

View File

@ -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,18 +79,18 @@ const VIDEO_INITIAL_MEDIA_STATE = {
*/
function _video(state = VIDEO_INITIAL_MEDIA_STATE, action) {
switch (action.type) {
case SET_VIDEO_AVAILABLE:
return {
...state,
available: action.available
};
case SET_CAMERA_FACING_MODE:
return {
...state,
facingMode: action.cameraFacingMode
};
case SET_VIDEO_AVAILABLE:
return {
...state,
available: action.available
};
case SET_VIDEO_MUTED:
return {
...state,

View File

@ -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;
}