jiti-meet/react/features/toolbox/actions.web.js

150 lines
3.7 KiB
JavaScript
Raw Normal View History

2019-03-19 15:42:25 +00:00
// @flow
2017-02-16 23:02:40 +00:00
2019-03-19 15:42:25 +00:00
import type { Dispatch } from 'redux';
2017-02-16 23:02:40 +00:00
import {
2017-04-01 05:52:40 +00:00
clearToolboxTimeout,
setToolboxTimeout,
setToolboxTimeoutMS,
setToolboxVisible
2017-02-16 23:02:40 +00:00
} from './actions.native';
import {
FULL_SCREEN_CHANGED,
SET_FULL_SCREEN
} from './actionTypes';
2017-02-16 23:02:40 +00:00
declare var interfaceConfig: Object;
export * from './actions.native';
2017-02-16 23:02:40 +00:00
/**
2017-04-01 05:52:40 +00:00
* Docks/undocks the Toolbox.
2017-02-16 23:02:40 +00:00
*
* @param {boolean} dock - True if dock, false otherwise.
* @returns {Function}
*/
2017-04-01 05:52:40 +00:00
export function dockToolbox(dock: boolean): Function {
2019-03-19 15:42:25 +00:00
return (dispatch: Dispatch<any>, getState: Function) => {
2017-02-16 23:02:40 +00:00
if (interfaceConfig.filmStripOnly) {
return;
}
2017-05-31 22:14:58 +00:00
const { timeoutMS, visible } = getState()['features/toolbox'];
2017-02-16 23:02:40 +00:00
if (dock) {
2017-04-01 05:52:40 +00:00
// First make sure the toolbox is shown.
visible || dispatch(showToolbox());
2017-02-16 23:02:40 +00:00
2017-04-01 05:52:40 +00:00
dispatch(clearToolboxTimeout());
2017-02-16 23:02:40 +00:00
} else if (visible) {
dispatch(
2017-04-01 05:52:40 +00:00
setToolboxTimeout(
() => dispatch(hideToolbox()),
timeoutMS));
2017-02-16 23:02:40 +00:00
} else {
2017-04-01 05:52:40 +00:00
dispatch(showToolbox());
2017-02-16 23:02:40 +00:00
}
};
}
/**
* Signals that full screen mode has been entered or exited.
*
* @param {boolean} fullScreen - Whether or not full screen mode is currently
* enabled.
* @returns {{
* type: FULL_SCREEN_CHANGED,
* fullScreen: boolean
* }}
*/
export function fullScreenChanged(fullScreen: boolean) {
return {
type: FULL_SCREEN_CHANGED,
fullScreen
};
}
2017-02-16 23:02:40 +00:00
/**
2017-04-01 05:52:40 +00:00
* Hides the toolbox.
2017-02-16 23:02:40 +00:00
*
2017-04-01 05:52:40 +00:00
* @param {boolean} force - True to force the hiding of the toolbox without
2017-02-16 23:02:40 +00:00
* caring about the extended toolbar side panels.
* @returns {Function}
*/
2017-04-01 05:52:40 +00:00
export function hideToolbox(force: boolean = false): Function {
2019-03-19 15:42:25 +00:00
return (dispatch: Dispatch<any>, getState: Function) => {
2017-02-16 23:02:40 +00:00
const state = getState();
const {
alwaysVisible,
hovered,
2017-04-01 05:52:40 +00:00
timeoutMS
} = state['features/toolbox'];
2017-02-16 23:02:40 +00:00
if (alwaysVisible) {
return;
}
2017-04-01 05:52:40 +00:00
dispatch(clearToolboxTimeout());
2017-02-16 23:02:40 +00:00
if (!force
&& (hovered
2018-06-26 22:56:22 +00:00
|| state['features/invite'].calleeInfoVisible
|| state['features/chat'].isOpen)) {
2017-02-16 23:02:40 +00:00
dispatch(
2017-04-01 05:52:40 +00:00
setToolboxTimeout(
() => dispatch(hideToolbox()),
timeoutMS));
2017-02-16 23:02:40 +00:00
} else {
2017-04-01 05:52:40 +00:00
dispatch(setToolboxVisible(false));
2017-02-16 23:02:40 +00:00
}
};
}
/**
* Signals a request to enter or exit full screen mode.
*
* @param {boolean} fullScreen - True to enter full screen mode, false to exit.
* @returns {{
* type: SET_FULL_SCREEN,
* fullScreen: boolean
* }}
*/
export function setFullScreen(fullScreen: boolean) {
return {
type: SET_FULL_SCREEN,
fullScreen
};
}
2017-02-16 23:02:40 +00:00
/**
2017-04-01 05:52:40 +00:00
* Shows the toolbox for specified timeout.
2017-02-16 23:02:40 +00:00
*
2017-04-01 05:52:40 +00:00
* @param {number} timeout - Timeout for showing the toolbox.
2017-02-16 23:02:40 +00:00
* @returns {Function}
*/
2017-04-01 05:52:40 +00:00
export function showToolbox(timeout: number = 0): Object {
2019-03-19 15:42:25 +00:00
return (dispatch: Dispatch<any>, getState: Function) => {
2017-02-16 23:02:40 +00:00
const state = getState();
const {
alwaysVisible,
enabled,
timeoutMS,
visible
} = state['features/toolbox'];
2017-02-16 23:02:40 +00:00
if (enabled && !visible) {
2017-04-01 05:52:40 +00:00
dispatch(setToolboxVisible(true));
// If the Toolbox is always visible, there's no need for a timeout
// to toggle its visibility.
if (!alwaysVisible) {
dispatch(
setToolboxTimeout(
() => dispatch(hideToolbox()),
timeout || timeoutMS));
dispatch(setToolboxTimeoutMS(interfaceConfig.TOOLBAR_TIMEOUT));
}
2017-02-16 23:02:40 +00:00
}
};
}