2019-01-30 17:19:40 +00:00
|
|
|
// @flow
|
|
|
|
|
2020-05-13 14:25:06 +00:00
|
|
|
import { TOOLBOX_ALWAYS_VISIBLE, getFeatureFlag } from '../base/flags';
|
2019-03-12 17:45:53 +00:00
|
|
|
import { toState } from '../base/redux';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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'];
|
2020-05-13 14:25:06 +00:00
|
|
|
const flag = getFeatureFlag(state, TOOLBOX_ALWAYS_VISIBLE, false);
|
2019-03-12 17:45:53 +00:00
|
|
|
|
2020-05-13 14:25:06 +00:00
|
|
|
return enabled && (alwaysVisible || visible || participantCount === 1 || flag);
|
2019-03-12 17:45:53 +00:00
|
|
|
}
|