jiti-meet/react/features/toolbox/reducer.js

177 lines
4.4 KiB
JavaScript
Raw Normal View History

// @flow
2017-02-16 23:02:40 +00:00
2018-05-18 13:19:25 +00:00
import { ReducerRegistry, set } from '../base/redux';
2017-02-16 23:02:40 +00:00
import {
2017-04-01 05:52:40 +00:00
CLEAR_TOOLBOX_TIMEOUT,
FULL_SCREEN_CHANGED,
SET_OVERFLOW_MENU_VISIBLE,
2017-02-16 23:02:40 +00:00
SET_TOOLBAR_HOVERED,
SET_TOOLBOX_ALWAYS_VISIBLE,
SET_TOOLBOX_ENABLED,
2017-04-01 05:52:40 +00:00
SET_TOOLBOX_TIMEOUT,
SET_TOOLBOX_TIMEOUT_MS,
SET_TOOLBOX_VISIBLE,
TOGGLE_TOOLBOX_VISIBLE
2017-02-16 23:02:40 +00:00
} from './actionTypes';
declare var interfaceConfig: Object;
/**
2017-04-01 05:52:40 +00:00
* Returns initial state for toolbox's part of Redux store.
2017-02-16 23:02:40 +00:00
*
2017-04-01 05:52:40 +00:00
* @private
2017-02-16 23:02:40 +00:00
* @returns {{
2017-04-01 05:52:40 +00:00
* alwaysVisible: boolean,
* enabled: boolean,
2017-04-01 05:52:40 +00:00
* hovered: boolean,
* overflowMenuVisible: boolean,
2017-04-01 05:52:40 +00:00
* timeoutID: number,
* timeoutMS: number,
* visible: boolean
2017-02-16 23:02:40 +00:00
* }}
*/
function _getInitialState() {
// Does the toolbar eventually fade out, or is it always visible?
let alwaysVisible = false;
// Toolbar (initial) visibility.
let visible = false;
2017-04-01 05:52:40 +00:00
// Default toolbox timeout for mobile app.
let timeoutMS = 5000;
2017-02-16 23:02:40 +00:00
if (typeof interfaceConfig !== 'undefined') {
if (interfaceConfig.INITIAL_TOOLBAR_TIMEOUT) {
timeoutMS = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
}
if (typeof interfaceConfig.TOOLBAR_ALWAYS_VISIBLE !== 'undefined') {
alwaysVisible = interfaceConfig.TOOLBAR_ALWAYS_VISIBLE;
}
}
// When the toolbar is always visible, it must initially be visible too.
if (alwaysVisible === true) {
visible = true;
2017-02-16 23:02:40 +00:00
}
return {
/**
2017-04-01 05:52:40 +00:00
* The indicator which determines whether the Toolbox should always be
* visible. When false, the toolbar will fade out after timeoutMS.
2017-02-16 23:02:40 +00:00
*
* @type {boolean}
*/
alwaysVisible,
2017-02-16 23:02:40 +00:00
/**
feat(recording): frontend logic can support live streaming and recording (#2952) * feat(recording): frontend logic can support live streaming and recording Instead of either live streaming or recording, now both can live together. The changes to facilitate such include the following: - Killing the state storing in Recording.js. Instead state is stored in the lib and updated in redux for labels to display the necessary state updates. - Creating a new container, Labels, for recording labels. Previously labels were manually created and positioned. The container can create a reasonable number of labels and only the container itself needs to be positioned with CSS. The VideoQualityLabel has been shoved into the container as well because it moves along with the recording labels. - The action for updating recording state has been modified to enable updating an array of recording sessions to support having multiple sessions. - Confirmation dialogs for stopping and starting a file recording session have been created, as they previously were jquery modals opened by Recording.js. - Toolbox.web displays live streaming and recording buttons based on configuration instead of recording availability. - VideoQualityLabel and RecordingLabel have been simplified to remove any positioning logic, as the Labels container handles such. - Previous recording state update logic has been moved into the RecordingLabel component. Each RecordingLabel is in charge of displaying state for a recording session. The display UX has been left alone. - Sipgw availability is no longer broadcast so remove logic depending on its state. Some moving around of code was necessary to get around linting errors about the existing code being too deeply nested (even though I didn't touch it). * work around lib-jitsi-meet circular dependency issues * refactor labels to use html base * pass in translation keys to video quality label * add video quality classnames for torture tests * break up, rearrange recorder session update listener * add comment about disabling startup resize animation * rename session to sessionData * chore(deps): update to latest lib for recording changes
2018-05-16 14:00:16 +00:00
* The indicator which determines whether the Toolbox is enabled.
*
* @type {boolean}
*/
enabled: true,
2017-02-16 23:02:40 +00:00
/**
2017-04-01 05:52:40 +00:00
* The indicator which determines whether a Toolbar in the Toolbox is
* hovered.
2017-02-16 23:02:40 +00:00
*
* @type {boolean}
*/
hovered: false,
/**
* The indicator which determines whether the OverflowMenu is visible.
*
* @type {boolean}
*/
overflowMenuVisible: false,
2017-02-16 23:02:40 +00:00
/**
2017-04-01 05:52:40 +00:00
* A number, non-zero value which identifies the timer created by a call
* to setTimeout() with timeoutMS.
2017-02-16 23:02:40 +00:00
*
* @type {number|null}
*/
2017-04-01 05:52:40 +00:00
timeoutID: null,
2017-02-16 23:02:40 +00:00
/**
2017-04-01 05:52:40 +00:00
* The delay in milliseconds before timeoutID executes (after its
* initialization).
2017-02-16 23:02:40 +00:00
*
* @type {number}
*/
2017-04-01 05:52:40 +00:00
timeoutMS,
2017-02-16 23:02:40 +00:00
/**
2017-04-01 05:52:40 +00:00
* The indicator which determines whether the Toolbox is visible.
2017-02-16 23:02:40 +00:00
*
* @type {boolean}
*/
visible
2017-02-16 23:02:40 +00:00
};
}
ReducerRegistry.register(
2017-04-01 05:52:40 +00:00
'features/toolbox',
2017-02-16 23:02:40 +00:00
(state: Object = _getInitialState(), action: Object) => {
switch (action.type) {
2017-04-01 05:52:40 +00:00
case CLEAR_TOOLBOX_TIMEOUT:
2017-02-16 23:02:40 +00:00
return {
...state,
2017-04-01 05:52:40 +00:00
timeoutID: undefined
2017-02-16 23:02:40 +00:00
};
case FULL_SCREEN_CHANGED:
return {
...state,
fullScreen: action.fullScreen
};
case SET_OVERFLOW_MENU_VISIBLE:
return {
...state,
overflowMenuVisible: action.visible
};
2017-02-16 23:02:40 +00:00
case SET_TOOLBAR_HOVERED:
return {
...state,
hovered: action.hovered
};
case SET_TOOLBOX_ALWAYS_VISIBLE:
return {
...state,
alwaysVisible: action.alwaysVisible,
visible: action.alwaysVisible === true ? true : state.visible
};
case SET_TOOLBOX_ENABLED:
return {
...state,
enabled: action.enabled
};
2017-04-01 05:52:40 +00:00
case SET_TOOLBOX_TIMEOUT:
2017-02-16 23:02:40 +00:00
return {
...state,
2017-04-01 05:52:40 +00:00
timeoutID: action.timeoutID,
timeoutMS: action.timeoutMS
2017-02-16 23:02:40 +00:00
};
2017-04-01 05:52:40 +00:00
case SET_TOOLBOX_TIMEOUT_MS:
2017-02-16 23:02:40 +00:00
return {
...state,
2017-04-01 05:52:40 +00:00
timeoutMS: action.timeoutMS
2017-02-16 23:02:40 +00:00
};
2017-04-01 05:52:40 +00:00
case SET_TOOLBOX_VISIBLE:
return set(state, 'visible', state.alwaysVisible || action.visible);
case TOGGLE_TOOLBOX_VISIBLE:
return set(state, 'visible', state.alwaysVisible || !state.visible);
2017-02-16 23:02:40 +00:00
}
return state;
});