2017-10-03 14:24:00 -05:00
|
|
|
// @flow
|
|
|
|
|
|
2021-03-10 17:39:35 +02:00
|
|
|
import { getToolbarButtons } from '../base/config';
|
2020-05-20 12:57:03 +02:00
|
|
|
import { hasAvailableDevices } from '../base/devices';
|
2020-04-16 13:47:10 +03:00
|
|
|
|
2021-09-23 17:39:05 +03:00
|
|
|
import { TOOLBAR_TIMEOUT } from './constants';
|
|
|
|
|
|
2021-11-30 15:08:25 -05:00
|
|
|
export * from './functions.any';
|
|
|
|
|
|
2018-03-06 16:28:19 -08:00
|
|
|
/**
|
|
|
|
|
* Helper for getting the height of the toolbox.
|
|
|
|
|
*
|
|
|
|
|
* @returns {number} The height of the toolbox.
|
|
|
|
|
*/
|
|
|
|
|
export function getToolboxHeight() {
|
|
|
|
|
const toolbox = document.getElementById('new-toolbox');
|
|
|
|
|
|
|
|
|
|
return (toolbox && toolbox.clientHeight) || 0;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-26 15:52:41 -05:00
|
|
|
/**
|
|
|
|
|
* Indicates if a toolbar button is enabled.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} name - The name of the setting section as defined in
|
|
|
|
|
* interface_config.js.
|
2021-03-10 17:39:35 +02:00
|
|
|
* @param {Object} state - The redux state.
|
2020-08-04 17:25:16 -05:00
|
|
|
* @returns {boolean|undefined} - True to indicate that the given toolbar button
|
2021-03-10 17:39:35 +02:00
|
|
|
* is enabled, false - otherwise.
|
2017-07-26 15:52:41 -05:00
|
|
|
*/
|
2021-03-10 17:39:35 +02:00
|
|
|
export function isButtonEnabled(name: string, state: Object) {
|
|
|
|
|
const toolbarButtons = getToolbarButtons(state);
|
2020-08-04 17:25:16 -05:00
|
|
|
|
2021-03-10 17:39:35 +02:00
|
|
|
return toolbarButtons.indexOf(name) !== -1;
|
2017-07-26 15:52:41 -05:00
|
|
|
}
|
2019-03-12 17:45:53 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicates if the toolbox is visible or not.
|
|
|
|
|
*
|
2021-09-10 15:17:57 +03:00
|
|
|
* @param {Object} state - The state from the Redux store.
|
2019-03-12 17:45:53 +00:00
|
|
|
* @returns {boolean} - True to indicate that the toolbox is visible, false -
|
|
|
|
|
* otherwise.
|
|
|
|
|
*/
|
|
|
|
|
export function isToolboxVisible(state: Object) {
|
2021-09-28 14:52:31 +03:00
|
|
|
const { iAmSipGateway, toolbarConfig } = state['features/base/config'];
|
|
|
|
|
const { alwaysVisible } = toolbarConfig || {};
|
2019-03-12 17:45:53 +00:00
|
|
|
const {
|
|
|
|
|
timeoutID,
|
|
|
|
|
visible
|
|
|
|
|
} = state['features/toolbox'];
|
2020-03-30 17:17:18 +03:00
|
|
|
const { audioSettingsVisible, videoSettingsVisible } = state['features/settings'];
|
2019-03-12 17:45:53 +00:00
|
|
|
|
2021-01-12 15:24:55 +02:00
|
|
|
return Boolean(!iAmSipGateway && (timeoutID || visible || alwaysVisible
|
2020-03-30 17:17:18 +03:00
|
|
|
|| audioSettingsVisible || videoSettingsVisible));
|
2019-03-12 17:45:53 +00:00
|
|
|
}
|
2020-04-16 13:47:10 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicates if the audio settings button is disabled or not.
|
|
|
|
|
*
|
2021-09-10 15:17:57 +03:00
|
|
|
* @param {Object} state - The state from the Redux store.
|
2020-04-16 13:47:10 +03:00
|
|
|
* @returns {boolean}
|
|
|
|
|
*/
|
|
|
|
|
export function isAudioSettingsButtonDisabled(state: Object) {
|
2021-11-30 15:08:25 -05:00
|
|
|
|
|
|
|
|
return !(hasAvailableDevices(state, 'audioInput')
|
|
|
|
|
&& hasAvailableDevices(state, 'audioOutput'))
|
2020-06-19 10:03:26 +03:00
|
|
|
|| state['features/base/config'].startSilent;
|
2020-04-16 13:47:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicates if the video settings button is disabled or not.
|
|
|
|
|
*
|
2021-09-10 15:17:57 +03:00
|
|
|
* @param {Object} state - The state from the Redux store.
|
2020-04-16 13:47:10 +03:00
|
|
|
* @returns {boolean}
|
|
|
|
|
*/
|
|
|
|
|
export function isVideoSettingsButtonDisabled(state: Object) {
|
2020-06-19 10:03:26 +03:00
|
|
|
return !hasAvailableDevices(state, 'videoInput');
|
2020-04-16 13:47:10 +03:00
|
|
|
}
|
2020-11-04 09:32:06 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicates if the video mute button is disabled or not.
|
|
|
|
|
*
|
2021-09-10 15:17:57 +03:00
|
|
|
* @param {Object} state - The state from the Redux store.
|
2020-11-04 09:32:06 +01:00
|
|
|
* @returns {boolean}
|
|
|
|
|
*/
|
|
|
|
|
export function isVideoMuteButtonDisabled(state: Object) {
|
2021-12-07 16:48:12 -05:00
|
|
|
const { muted, unmuteBlocked } = state['features/base/media'].video;
|
2021-11-30 15:08:25 -05:00
|
|
|
|
2021-12-07 16:48:12 -05:00
|
|
|
return !hasAvailableDevices(state, 'videoInput') || (unmuteBlocked && Boolean(muted));
|
2020-11-04 09:32:06 +01:00
|
|
|
}
|
2021-09-10 14:05:16 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If an overflow drawer should be displayed or not.
|
|
|
|
|
* This is usually done for mobile devices or on narrow screens.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} state - The state from the Redux store.
|
|
|
|
|
* @returns {boolean}
|
|
|
|
|
*/
|
|
|
|
|
export function showOverflowDrawer(state: Object) {
|
|
|
|
|
return state['features/toolbox'].overflowDrawer;
|
|
|
|
|
}
|
2021-09-10 15:17:57 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicates whether the toolbox is enabled or not.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} state - The state from the Redux store.
|
|
|
|
|
* @returns {boolean}
|
|
|
|
|
*/
|
|
|
|
|
export function isToolboxEnabled(state: Object) {
|
|
|
|
|
return state['features/toolbox'].enabled;
|
|
|
|
|
}
|
2021-09-23 17:39:05 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the toolbar timeout from config or the default value.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} state - The state from the Redux store.
|
|
|
|
|
* @returns {number} - Toolbar timeout in miliseconds.
|
|
|
|
|
*/
|
|
|
|
|
export function getToolbarTimeout(state: Object) {
|
|
|
|
|
const { toolbarConfig: { timeout } } = state['features/base/config'];
|
|
|
|
|
|
|
|
|
|
return timeout || TOOLBAR_TIMEOUT;
|
|
|
|
|
}
|