2022-09-29 11:45:34 +00:00
|
|
|
import { IState } from '../app/types';
|
|
|
|
import { getToolbarButtons } from '../base/config/functions.web';
|
|
|
|
import { hasAvailableDevices } from '../base/devices/functions';
|
2022-10-17 15:32:18 +00:00
|
|
|
import { MEET_FEATURES } from '../base/jwt/constants';
|
|
|
|
import { isJwtFeatureEnabled } from '../base/jwt/functions';
|
2022-01-05 20:27:42 +00:00
|
|
|
import { isScreenMediaShared } from '../screen-share/functions';
|
2022-09-30 14:50:45 +00:00
|
|
|
import { isWhiteboardVisible } from '../whiteboard/functions';
|
2020-04-16 10:47:10 +00:00
|
|
|
|
2021-09-23 14:39:05 +00:00
|
|
|
import { TOOLBAR_TIMEOUT } from './constants';
|
|
|
|
|
2021-11-30 20:08:25 +00:00
|
|
|
export * from './functions.any';
|
|
|
|
|
2018-03-07 00:28:19 +00: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');
|
|
|
|
|
2022-09-29 11:45:34 +00:00
|
|
|
return toolbox?.clientHeight || 0;
|
2018-03-07 00:28:19 +00:00
|
|
|
}
|
|
|
|
|
2017-07-26 20:52:41 +00:00
|
|
|
/**
|
|
|
|
* Indicates if a toolbar button is enabled.
|
|
|
|
*
|
|
|
|
* @param {string} name - The name of the setting section as defined in
|
|
|
|
* interface_config.js.
|
2022-09-29 11:45:34 +00:00
|
|
|
* @param {IState} state - The redux state.
|
2020-08-04 22:25:16 +00:00
|
|
|
* @returns {boolean|undefined} - True to indicate that the given toolbar button
|
2021-03-10 15:39:35 +00:00
|
|
|
* is enabled, false - otherwise.
|
2017-07-26 20:52:41 +00:00
|
|
|
*/
|
2022-09-29 11:45:34 +00:00
|
|
|
export function isButtonEnabled(name: string, state: IState) {
|
2021-03-10 15:39:35 +00:00
|
|
|
const toolbarButtons = getToolbarButtons(state);
|
2020-08-04 22:25:16 +00:00
|
|
|
|
2021-03-10 15:39:35 +00:00
|
|
|
return toolbarButtons.indexOf(name) !== -1;
|
2017-07-26 20:52:41 +00:00
|
|
|
}
|
2019-03-12 17:45:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates if the toolbox is visible or not.
|
|
|
|
*
|
2022-09-29 11:45:34 +00:00
|
|
|
* @param {IState} 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.
|
|
|
|
*/
|
2022-09-29 11:45:34 +00:00
|
|
|
export function isToolboxVisible(state: IState) {
|
2022-02-04 09:55:34 +00:00
|
|
|
const { iAmRecorder, iAmSipGateway, toolbarConfig } = state['features/base/config'];
|
2021-09-28 11:52:31 +00:00
|
|
|
const { alwaysVisible } = toolbarConfig || {};
|
2019-03-12 17:45:53 +00:00
|
|
|
const {
|
|
|
|
timeoutID,
|
|
|
|
visible
|
|
|
|
} = state['features/toolbox'];
|
2020-03-30 14:17:18 +00:00
|
|
|
const { audioSettingsVisible, videoSettingsVisible } = state['features/settings'];
|
2022-09-30 14:50:45 +00:00
|
|
|
const whiteboardVisible = isWhiteboardVisible(state);
|
2019-03-12 17:45:53 +00:00
|
|
|
|
2022-02-04 09:55:34 +00:00
|
|
|
return Boolean(!iAmRecorder && !iAmSipGateway
|
2022-09-30 14:50:45 +00:00
|
|
|
&& (
|
|
|
|
timeoutID
|
|
|
|
|| visible
|
|
|
|
|| alwaysVisible
|
|
|
|
|| audioSettingsVisible
|
|
|
|
|| videoSettingsVisible
|
|
|
|
|| whiteboardVisible
|
|
|
|
));
|
2019-03-12 17:45:53 +00:00
|
|
|
}
|
2020-04-16 10:47:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates if the audio settings button is disabled or not.
|
|
|
|
*
|
2022-09-29 11:45:34 +00:00
|
|
|
* @param {IState} state - The state from the Redux store.
|
2020-04-16 10:47:10 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-09-29 11:45:34 +00:00
|
|
|
export function isAudioSettingsButtonDisabled(state: IState) {
|
2021-11-30 20:08:25 +00:00
|
|
|
|
|
|
|
return !(hasAvailableDevices(state, 'audioInput')
|
2022-09-29 11:45:34 +00:00
|
|
|
|| hasAvailableDevices(state, 'audioOutput'))
|
|
|
|
|| state['features/base/config'].startSilent;
|
2020-04-16 10:47:10 +00:00
|
|
|
}
|
|
|
|
|
2022-01-05 20:27:42 +00:00
|
|
|
/**
|
|
|
|
* Indicates if the desktop share button is disabled or not.
|
|
|
|
*
|
2022-09-29 11:45:34 +00:00
|
|
|
* @param {IState} state - The state from the Redux store.
|
2022-01-05 20:27:42 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-09-29 11:45:34 +00:00
|
|
|
export function isDesktopShareButtonDisabled(state: IState) {
|
2022-01-05 20:27:42 +00:00
|
|
|
const { muted, unmuteBlocked } = state['features/base/media'].video;
|
|
|
|
const videoOrShareInProgress = !muted || isScreenMediaShared(state);
|
2022-10-17 15:32:18 +00:00
|
|
|
const enabledInJwt = isJwtFeatureEnabled(state, MEET_FEATURES.SCREEN_SHARING, true, true);
|
2022-01-05 20:27:42 +00:00
|
|
|
|
2022-10-17 15:32:18 +00:00
|
|
|
return !enabledInJwt || (unmuteBlocked && !videoOrShareInProgress);
|
2022-01-05 20:27:42 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
/**
|
|
|
|
* Indicates if the video settings button is disabled or not.
|
|
|
|
*
|
2022-09-29 11:45:34 +00:00
|
|
|
* @param {IState} state - The state from the Redux store.
|
2020-04-16 10:47:10 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-09-29 11:45:34 +00:00
|
|
|
export function isVideoSettingsButtonDisabled(state: IState) {
|
2020-06-19 07:03:26 +00:00
|
|
|
return !hasAvailableDevices(state, 'videoInput');
|
2020-04-16 10:47:10 +00:00
|
|
|
}
|
2020-11-04 08:32:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates if the video mute button is disabled or not.
|
|
|
|
*
|
2022-09-29 11:45:34 +00:00
|
|
|
* @param {IState} state - The state from the Redux store.
|
2020-11-04 08:32:06 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-09-29 11:45:34 +00:00
|
|
|
export function isVideoMuteButtonDisabled(state: IState) {
|
2021-12-07 21:48:12 +00:00
|
|
|
const { muted, unmuteBlocked } = state['features/base/media'].video;
|
2021-11-30 20:08:25 +00:00
|
|
|
|
2021-12-07 21:48:12 +00:00
|
|
|
return !hasAvailableDevices(state, 'videoInput') || (unmuteBlocked && Boolean(muted));
|
2020-11-04 08:32:06 +00:00
|
|
|
}
|
2021-09-10 11:05:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If an overflow drawer should be displayed or not.
|
|
|
|
* This is usually done for mobile devices or on narrow screens.
|
|
|
|
*
|
2022-09-29 11:45:34 +00:00
|
|
|
* @param {IState} state - The state from the Redux store.
|
2021-09-10 11:05:16 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-09-29 11:45:34 +00:00
|
|
|
export function showOverflowDrawer(state: IState) {
|
2021-09-10 11:05:16 +00:00
|
|
|
return state['features/toolbox'].overflowDrawer;
|
|
|
|
}
|
2021-09-10 12:17:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the toolbox is enabled or not.
|
|
|
|
*
|
2022-09-29 11:45:34 +00:00
|
|
|
* @param {IState} state - The state from the Redux store.
|
2021-09-10 12:17:57 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-09-29 11:45:34 +00:00
|
|
|
export function isToolboxEnabled(state: IState) {
|
2021-09-10 12:17:57 +00:00
|
|
|
return state['features/toolbox'].enabled;
|
|
|
|
}
|
2021-09-23 14:39:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the toolbar timeout from config or the default value.
|
|
|
|
*
|
2022-09-29 11:45:34 +00:00
|
|
|
* @param {IState} state - The state from the Redux store.
|
2022-08-30 14:21:58 +00:00
|
|
|
* @returns {number} - Toolbar timeout in milliseconds.
|
2021-09-23 14:39:05 +00:00
|
|
|
*/
|
2022-09-29 11:45:34 +00:00
|
|
|
export function getToolbarTimeout(state: IState) {
|
|
|
|
const { toolbarConfig } = state['features/base/config'];
|
2021-09-23 14:39:05 +00:00
|
|
|
|
2022-09-29 11:45:34 +00:00
|
|
|
return toolbarConfig?.timeout || TOOLBAR_TIMEOUT;
|
2021-09-23 14:39:05 +00:00
|
|
|
}
|