2022-10-19 11:38:38 +00:00
|
|
|
import { IStore } from '../app/types';
|
|
|
|
import { overwriteConfig } from '../base/config/actions';
|
2021-10-25 09:16:03 +00:00
|
|
|
import { isMobileBrowser } from '../base/environment/utils';
|
2021-09-10 12:17:57 +00:00
|
|
|
|
2020-05-20 10:57:03 +00:00
|
|
|
import {
|
2021-09-23 09:20:11 +00:00
|
|
|
CLEAR_TOOLBOX_TIMEOUT,
|
2020-05-20 10:57:03 +00:00
|
|
|
FULL_SCREEN_CHANGED,
|
2021-01-04 13:30:23 +00:00
|
|
|
SET_FULL_SCREEN,
|
2022-08-26 18:25:04 +00:00
|
|
|
SET_HANGUP_MENU_VISIBLE,
|
2021-09-23 09:20:11 +00:00
|
|
|
SET_OVERFLOW_DRAWER,
|
|
|
|
SET_OVERFLOW_MENU_VISIBLE,
|
|
|
|
SET_TOOLBAR_HOVERED,
|
2021-09-23 14:39:05 +00:00
|
|
|
SET_TOOLBOX_TIMEOUT
|
2020-05-20 10:57:03 +00:00
|
|
|
} from './actionTypes';
|
2022-10-19 11:38:38 +00:00
|
|
|
import { setToolboxVisible } from './actions.web';
|
|
|
|
import { getToolbarTimeout } from './functions.web';
|
2017-02-16 23:02:40 +00:00
|
|
|
|
2021-09-23 09:20:11 +00:00
|
|
|
export * from './actions.any';
|
2017-05-01 23:04:12 +00:00
|
|
|
|
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}
|
|
|
|
*/
|
2022-10-19 11:38:38 +00:00
|
|
|
export function dockToolbox(dock: boolean) {
|
|
|
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2021-09-23 14:39:05 +00:00
|
|
|
const state = getState();
|
|
|
|
const { visible } = state['features/toolbox'];
|
|
|
|
const toolbarTimeout = getToolbarTimeout(state);
|
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()),
|
2021-09-23 14:39:05 +00:00
|
|
|
toolbarTimeout));
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-03-07 00:28:19 +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}
|
|
|
|
*/
|
2022-10-19 11:38:38 +00:00
|
|
|
export function hideToolbox(force = false) {
|
|
|
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2017-02-16 23:02:40 +00:00
|
|
|
const state = getState();
|
2022-10-19 11:38:38 +00:00
|
|
|
const { toolbarConfig } = state['features/base/config'];
|
|
|
|
const alwaysVisible = toolbarConfig?.alwaysVisible;
|
|
|
|
const autoHideWhileChatIsOpen = toolbarConfig?.autoHideWhileChatIsOpen;
|
2021-09-23 14:39:05 +00:00
|
|
|
const { hovered } = state['features/toolbox'];
|
|
|
|
const toolbarTimeout = getToolbarTimeout(state);
|
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
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
const focusSelector = '.toolbox-content-items:focus-within,.filmstrip:focus-within,.remotevideomenu:hover';
|
|
|
|
|
2017-02-16 23:02:40 +00:00
|
|
|
if (!force
|
|
|
|
&& (hovered
|
2018-06-26 22:56:22 +00:00
|
|
|
|| state['features/invite'].calleeInfoVisible
|
2022-03-14 08:30:31 +00:00
|
|
|
|| (state['features/chat'].isOpen && !autoHideWhileChatIsOpen)
|
2021-06-10 12:48:44 +00:00
|
|
|
|| document.querySelector(focusSelector))) {
|
2017-02-16 23:02:40 +00:00
|
|
|
dispatch(
|
2017-04-01 05:52:40 +00:00
|
|
|
setToolboxTimeout(
|
|
|
|
() => dispatch(hideToolbox()),
|
2021-09-23 14:39:05 +00:00
|
|
|
toolbarTimeout));
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-03-07 00:28:19 +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}
|
|
|
|
*/
|
2022-10-19 11:38:38 +00:00
|
|
|
export function showToolbox(timeout = 0) {
|
|
|
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2017-02-16 23:02:40 +00:00
|
|
|
const state = getState();
|
2022-10-19 11:38:38 +00:00
|
|
|
const { toolbarConfig } = state['features/base/config'];
|
2021-09-23 14:39:05 +00:00
|
|
|
const toolbarTimeout = getToolbarTimeout(state);
|
2022-10-19 11:38:38 +00:00
|
|
|
const initialTimeout = toolbarConfig?.initialTimeout;
|
|
|
|
const alwaysVisible = toolbarConfig?.alwaysVisible;
|
2021-09-23 14:39:05 +00:00
|
|
|
|
|
|
|
const {
|
2017-04-12 19:06:56 +00:00
|
|
|
enabled,
|
2021-10-06 09:53:27 +00:00
|
|
|
visible
|
2017-04-12 19:06:56 +00:00
|
|
|
} = state['features/toolbox'];
|
2017-02-16 23:02:40 +00:00
|
|
|
|
2021-10-06 09:53:27 +00:00
|
|
|
if (enabled && !visible) {
|
2017-04-01 05:52:40 +00:00
|
|
|
dispatch(setToolboxVisible(true));
|
2017-04-06 18:43:36 +00:00
|
|
|
|
|
|
|
// If the Toolbox is always visible, there's no need for a timeout
|
|
|
|
// to toggle its visibility.
|
|
|
|
if (!alwaysVisible) {
|
2021-09-23 14:39:05 +00:00
|
|
|
if (typeof initialTimeout === 'number') {
|
|
|
|
// reset `initialTimeout` once it is consumed once
|
|
|
|
dispatch(overwriteConfig({ toolbarConfig: {
|
|
|
|
...toolbarConfig,
|
|
|
|
initialTimeout: null
|
|
|
|
} }));
|
|
|
|
}
|
2017-04-06 18:43:36 +00:00
|
|
|
dispatch(
|
|
|
|
setToolboxTimeout(
|
|
|
|
() => dispatch(hideToolbox()),
|
2021-09-23 14:39:05 +00:00
|
|
|
timeout || initialTimeout || toolbarTimeout));
|
2017-04-06 18:43:36 +00:00
|
|
|
}
|
2017-02-16 23:02:40 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2021-01-04 13:30:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Signals a request to display overflow as drawer.
|
|
|
|
*
|
|
|
|
* @param {boolean} displayAsDrawer - True to display overflow as drawer, false to preserve original behaviour.
|
|
|
|
* @returns {{
|
|
|
|
* type: SET_OVERFLOW_DRAWER,
|
|
|
|
* displayAsDrawer: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function setOverflowDrawer(displayAsDrawer: boolean) {
|
|
|
|
return {
|
|
|
|
type: SET_OVERFLOW_DRAWER,
|
|
|
|
displayAsDrawer
|
|
|
|
};
|
|
|
|
}
|
2021-09-10 12:17:57 +00:00
|
|
|
|
2021-09-23 09:20:11 +00:00
|
|
|
/**
|
|
|
|
* Signals that toolbox timeout should be cleared.
|
|
|
|
*
|
|
|
|
* @returns {{
|
|
|
|
* type: CLEAR_TOOLBOX_TIMEOUT
|
|
|
|
* }}
|
|
|
|
*/
|
2022-10-19 11:38:38 +00:00
|
|
|
export function clearToolboxTimeout() {
|
2021-09-23 09:20:11 +00:00
|
|
|
return {
|
|
|
|
type: CLEAR_TOOLBOX_TIMEOUT
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-08-26 18:25:04 +00:00
|
|
|
/**
|
|
|
|
* Shows/hides the hangup menu.
|
|
|
|
*
|
|
|
|
* @param {boolean} visible - True to show it or false to hide it.
|
|
|
|
* @returns {{
|
|
|
|
* type: SET_HANGUP_MENU_VISIBLE,
|
|
|
|
* visible: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function setHangupMenuVisible(visible: boolean): Object {
|
|
|
|
return {
|
|
|
|
type: SET_HANGUP_MENU_VISIBLE,
|
|
|
|
visible
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-09-23 09:20:11 +00:00
|
|
|
/**
|
|
|
|
* Shows/hides the overflow menu.
|
|
|
|
*
|
|
|
|
* @param {boolean} visible - True to show it or false to hide it.
|
|
|
|
* @returns {{
|
|
|
|
* type: SET_OVERFLOW_MENU_VISIBLE,
|
|
|
|
* visible: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function setOverflowMenuVisible(visible: boolean): Object {
|
|
|
|
return {
|
|
|
|
type: SET_OVERFLOW_MENU_VISIBLE,
|
|
|
|
visible
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signals that toolbar is hovered value should be changed.
|
|
|
|
*
|
|
|
|
* @param {boolean} hovered - Flag showing whether toolbar is hovered.
|
|
|
|
* @returns {{
|
|
|
|
* type: SET_TOOLBAR_HOVERED,
|
|
|
|
* hovered: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function setToolbarHovered(hovered: boolean): Object {
|
|
|
|
return {
|
|
|
|
type: SET_TOOLBAR_HOVERED,
|
|
|
|
hovered
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-25 09:16:03 +00:00
|
|
|
* Dispatches an action which sets new timeout for the toolbox visibility and clears the previous one.
|
|
|
|
* On mobile browsers the toolbox does not hide on timeout. It is toggled on simple tap.
|
2021-09-23 09:20:11 +00:00
|
|
|
*
|
|
|
|
* @param {Function} handler - Function to be invoked after the timeout.
|
|
|
|
* @param {number} timeoutMS - Delay.
|
|
|
|
* @returns {{
|
|
|
|
* type: SET_TOOLBOX_TIMEOUT,
|
|
|
|
* handler: Function,
|
|
|
|
* timeoutMS: number
|
|
|
|
* }}
|
|
|
|
*/
|
2022-10-19 11:38:38 +00:00
|
|
|
export function setToolboxTimeout(handler: Function, timeoutMS: number) {
|
|
|
|
return function(dispatch: IStore['dispatch']) {
|
2021-10-25 09:16:03 +00:00
|
|
|
if (isMobileBrowser()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: SET_TOOLBOX_TIMEOUT,
|
|
|
|
handler,
|
|
|
|
timeoutMS
|
|
|
|
});
|
2021-09-23 09:20:11 +00:00
|
|
|
};
|
|
|
|
}
|