2019-01-30 17:19:40 +00:00
|
|
|
// @flow
|
|
|
|
|
2020-11-04 08:32:06 +00:00
|
|
|
import { hasAvailableDevices } from '../base/devices';
|
2021-01-22 10:03:39 +00:00
|
|
|
import { TOOLBOX_ALWAYS_VISIBLE, getFeatureFlag, TOOLBOX_ENABLED } from '../base/flags';
|
2019-03-12 17:45:53 +00:00
|
|
|
import { toState } from '../base/redux';
|
2020-11-04 08:32:06 +00:00
|
|
|
import { isLocalVideoTrackDesktop } from '../base/tracks';
|
2019-03-12 17:45:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the toolbox is visible.
|
|
|
|
*
|
|
|
|
* @param {Object | Function} stateful - A function or object that can be
|
|
|
|
* resolved to Redux state by the function {@code toState}.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isToolboxVisible(stateful: Object | Function) {
|
2019-08-20 13:12:38 +00:00
|
|
|
const state = toState(stateful);
|
|
|
|
const { alwaysVisible, enabled, visible } = state['features/toolbox'];
|
|
|
|
const { length: participantCount } = state['features/base/participants'];
|
2021-01-22 10:03:39 +00:00
|
|
|
const alwaysVisibleFlag = getFeatureFlag(state, TOOLBOX_ALWAYS_VISIBLE, false);
|
|
|
|
const enabledFlag = getFeatureFlag(state, TOOLBOX_ENABLED, true);
|
2019-03-12 17:45:53 +00:00
|
|
|
|
2021-01-22 10:03:39 +00:00
|
|
|
return enabledFlag && enabled && (alwaysVisible || visible || participantCount === 1 || alwaysVisibleFlag);
|
2019-03-12 17:45:53 +00:00
|
|
|
}
|
2020-11-04 08:32:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates if the video mute button is disabled or not.
|
|
|
|
*
|
|
|
|
* @param {string} state - The state from the Redux store.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isVideoMuteButtonDisabled(state: Object) {
|
|
|
|
return !hasAvailableDevices(state, 'videoInput') || isLocalVideoTrackDesktop(state);
|
|
|
|
}
|