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

147 lines
3.3 KiB
TypeScript
Raw Normal View History

2022-09-01 11:00:49 +00:00
import ReducerRegistry from '../base/redux/ReducerRegistry';
import { set } from '../base/redux/functions';
2017-02-16 23:02:40 +00:00
import {
2017-04-01 05:52:40 +00:00
CLEAR_TOOLBOX_TIMEOUT,
FULL_SCREEN_CHANGED,
SET_HANGUP_MENU_VISIBLE,
SET_OVERFLOW_DRAWER,
SET_OVERFLOW_MENU_VISIBLE,
2017-02-16 23:02:40 +00:00
SET_TOOLBAR_HOVERED,
SET_TOOLBOX_ENABLED,
2017-04-01 05:52:40 +00:00
SET_TOOLBOX_TIMEOUT,
SET_TOOLBOX_VISIBLE,
TOGGLE_TOOLBOX_VISIBLE
2017-02-16 23:02:40 +00:00
} from './actionTypes';
/**
* Initial state of toolbox's part of Redux store.
2017-02-16 23:02:40 +00:00
*/
const INITIAL_STATE = {
/**
* The indicator which determines whether the Toolbox is enabled.
*
* @type {boolean}
*/
enabled: true,
/**
* The indicator which determines whether the hangup menu is visible.
*
* @type {boolean}
*/
hangupMenuVisible: false,
/**
* The indicator which determines whether a Toolbar in the Toolbox is
* hovered.
*
* @type {boolean}
*/
hovered: false,
/**
* The indicator which determines whether the overflow menu(s) are to be displayed as drawers.
*
* @type {boolean}
*/
overflowDrawer: false,
/**
* The indicator which determines whether the OverflowMenu is visible.
*
* @type {boolean}
*/
overflowMenuVisible: false,
/**
* A number, non-zero value which identifies the timer created by a call
* to setTimeout().
*
* @type {number|null}
*/
timeoutID: null,
/**
* The indicator that determines whether the Toolbox is visible.
*
* @type {boolean}
*/
visible: false
};
2017-02-16 23:02:40 +00:00
2022-09-01 11:00:49 +00:00
export interface IToolboxState {
enabled: boolean;
fullScreen?: boolean;
hangupMenuVisible: boolean;
hovered: boolean;
overflowDrawer: boolean;
overflowMenuVisible: boolean;
timeoutID?: number | null;
2022-09-01 11:00:49 +00:00
visible: boolean;
}
2022-09-05 09:05:07 +00:00
ReducerRegistry.register<IToolboxState>(
2017-04-01 05:52:40 +00:00
'features/toolbox',
2022-09-05 09:05:07 +00:00
(state = INITIAL_STATE, action): IToolboxState => {
2017-02-16 23:02:40 +00:00
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_HANGUP_MENU_VISIBLE:
return {
...state,
hangupMenuVisible: action.visible
};
case SET_OVERFLOW_DRAWER:
return {
...state,
overflowDrawer: action.displayAsDrawer
};
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_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,
timeoutID: action.timeoutID
2017-02-16 23:02:40 +00:00
};
2017-04-01 05:52:40 +00:00
case SET_TOOLBOX_VISIBLE:
return set(state, 'visible', action.visible);
case TOGGLE_TOOLBOX_VISIBLE:
return set(state, 'visible', !state.visible);
2017-02-16 23:02:40 +00:00
}
return state;
});