2017-10-03 19:24:00 +00:00
|
|
|
// @flow
|
|
|
|
|
2020-05-20 10:57:03 +00:00
|
|
|
import { hasAvailableDevices } from '../base/devices';
|
2020-04-16 10:47:10 +00:00
|
|
|
import {
|
|
|
|
isAudioDisabled,
|
|
|
|
isPrejoinPageVisible,
|
|
|
|
isPrejoinVideoDisabled
|
|
|
|
} from '../prejoin';
|
|
|
|
|
2017-04-01 05:52:40 +00:00
|
|
|
declare var interfaceConfig: Object;
|
|
|
|
|
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');
|
|
|
|
|
|
|
|
return (toolbox && toolbox.clientHeight) || 0;
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
* @returns {boolean} - True to indicate that the given toolbar button
|
|
|
|
* is enabled, false - otherwise.
|
|
|
|
*/
|
2017-10-03 19:24:00 +00:00
|
|
|
export function isButtonEnabled(name: string) {
|
2018-04-10 20:51:37 +00:00
|
|
|
return interfaceConfig.TOOLBAR_BUTTONS.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.
|
|
|
|
*
|
|
|
|
* @param {string} state - The state from the Redux store.
|
|
|
|
* @returns {boolean} - True to indicate that the toolbox is visible, false -
|
|
|
|
* otherwise.
|
|
|
|
*/
|
|
|
|
export function isToolboxVisible(state: Object) {
|
2020-02-25 10:49:49 +00:00
|
|
|
const { iAmSipGateway } = state['features/base/config'];
|
2019-03-12 17:45:53 +00:00
|
|
|
const {
|
|
|
|
alwaysVisible,
|
|
|
|
timeoutID,
|
|
|
|
visible
|
|
|
|
} = state['features/toolbox'];
|
2020-03-30 14:17:18 +00:00
|
|
|
const { audioSettingsVisible, videoSettingsVisible } = state['features/settings'];
|
2019-03-12 17:45:53 +00:00
|
|
|
|
2020-03-30 14:17:18 +00:00
|
|
|
return Boolean(!iAmSipGateway && (timeoutID || visible || alwaysVisible
|
|
|
|
|| audioSettingsVisible || videoSettingsVisible));
|
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.
|
|
|
|
*
|
|
|
|
* @param {string} state - The state from the Redux store.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isAudioSettingsButtonDisabled(state: Object) {
|
|
|
|
const devicesMissing = !hasAvailableDevices(state, 'audioInput')
|
|
|
|
&& !hasAvailableDevices(state, 'audioOutput');
|
|
|
|
|
|
|
|
return isPrejoinPageVisible(state)
|
|
|
|
? devicesMissing || isAudioDisabled(state)
|
|
|
|
: devicesMissing;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates if the video settings button is disabled or not.
|
|
|
|
*
|
|
|
|
* @param {string} state - The state from the Redux store.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isVideoSettingsButtonDisabled(state: Object) {
|
|
|
|
const devicesMissing = !hasAvailableDevices(state, 'videoInput');
|
|
|
|
|
|
|
|
return isPrejoinPageVisible(state)
|
|
|
|
? devicesMissing || isPrejoinVideoDisabled(state)
|
|
|
|
: devicesMissing;
|
|
|
|
}
|