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

146 lines
3.4 KiB
JavaScript
Raw Normal View History

// @flow
2017-02-16 23:02:40 +00:00
import { ReducerRegistry } from '../base/redux';
import {
2017-04-01 05:52:40 +00:00
CLEAR_TOOLBOX_TIMEOUT,
FULL_SCREEN_CHANGED,
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
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,
* timeoutID: number,
* timeoutMS: number,
* visible: boolean
2017-02-16 23:02:40 +00:00
* }}
*/
function _getInitialState() {
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'
&& interfaceConfig.INITIAL_TOOLBAR_TIMEOUT) {
2017-04-01 05:52:40 +00:00
timeoutMS = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
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.
2017-02-16 23:02:40 +00:00
*
* @type {boolean}
*/
alwaysVisible: false,
/**
* The indicator which determines whether the Toolbox is enabled. For
* example, modules/UI/recording/Recording.js disables the Toolbox.
*
* @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,
/**
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: false
};
}
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
};
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
};
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:
2017-02-16 23:02:40 +00:00
return {
...state,
visible: action.visible
};
}
return state;
});