2022-10-20 09:11:27 +00:00
|
|
|
import { IReduxState } from '../app/types';
|
2022-10-19 11:38:38 +00:00
|
|
|
import { IStateful } from '../base/app/types';
|
2022-10-21 11:09:15 +00:00
|
|
|
import { hasAvailableDevices } from '../base/devices/functions';
|
|
|
|
import { TOOLBOX_ALWAYS_VISIBLE, TOOLBOX_ENABLED } from '../base/flags/constants';
|
|
|
|
import { getFeatureFlag } from '../base/flags/functions';
|
|
|
|
import { getParticipantCountWithFake } from '../base/participants/functions';
|
|
|
|
import { toState } from '../base/redux/functions';
|
|
|
|
import { isLocalVideoTrackDesktop } from '../base/tracks/functions';
|
2019-03-12 17:45:53 +00:00
|
|
|
|
2021-11-30 20:08:25 +00:00
|
|
|
export * from './functions.any';
|
|
|
|
|
2021-03-22 09:02:57 +00:00
|
|
|
const WIDTH = {
|
|
|
|
FIT_9_ICONS: 560,
|
|
|
|
FIT_8_ICONS: 500,
|
|
|
|
FIT_7_ICONS: 440,
|
|
|
|
FIT_6_ICONS: 380
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a set of the buttons that are shown in the toolbar
|
|
|
|
* but removed from the overflow menu, based on the width of the screen.
|
|
|
|
*
|
|
|
|
* @param {number} width - The width of the screen.
|
|
|
|
* @returns {Set}
|
|
|
|
*/
|
|
|
|
export function getMovableButtons(width: number): Set<string> {
|
2022-10-19 11:38:38 +00:00
|
|
|
let buttons: string[] = [];
|
2021-03-22 09:02:57 +00:00
|
|
|
|
|
|
|
switch (true) {
|
|
|
|
case width >= WIDTH.FIT_9_ICONS: {
|
2022-09-26 20:33:27 +00:00
|
|
|
buttons = [ 'chat', 'togglecamera', 'screensharing', 'raisehand', 'tileview' ];
|
2021-03-22 09:02:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case width >= WIDTH.FIT_8_ICONS: {
|
2021-03-23 07:44:58 +00:00
|
|
|
buttons = [ 'chat', 'togglecamera', 'raisehand', 'tileview' ];
|
2021-03-22 09:02:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case width >= WIDTH.FIT_7_ICONS: {
|
2021-03-23 07:44:58 +00:00
|
|
|
buttons = [ 'chat', 'togglecamera', 'raisehand' ];
|
2021-03-22 09:02:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case width >= WIDTH.FIT_6_ICONS: {
|
2021-03-23 07:44:58 +00:00
|
|
|
buttons = [ 'chat', 'togglecamera' ];
|
2021-03-22 09:02:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default: {
|
|
|
|
buttons = [ 'chat' ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Set(buttons);
|
|
|
|
}
|
|
|
|
|
2022-01-05 20:27:42 +00:00
|
|
|
/**
|
|
|
|
* Indicates if the desktop share button is disabled or not.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state from the Redux store.
|
2022-01-05 20:27:42 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function isDesktopShareButtonDisabled(state: IReduxState) {
|
2022-01-05 20:27:42 +00:00
|
|
|
const { muted, unmuteBlocked } = state['features/base/media'].video;
|
|
|
|
const videoOrShareInProgress = !muted || isLocalVideoTrackDesktop(state);
|
|
|
|
|
|
|
|
return unmuteBlocked && !videoOrShareInProgress;
|
|
|
|
}
|
|
|
|
|
2019-03-12 17:45:53 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the toolbox is visible.
|
|
|
|
*
|
2022-10-19 11:38:38 +00:00
|
|
|
* @param {IStateful} stateful - A function or object that can be
|
2019-03-12 17:45:53 +00:00
|
|
|
* resolved to Redux state by the function {@code toState}.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-19 11:38:38 +00:00
|
|
|
export function isToolboxVisible(stateful: IStateful) {
|
2019-08-20 13:12:38 +00:00
|
|
|
const state = toState(stateful);
|
2021-09-28 11:52:31 +00:00
|
|
|
const { toolbarConfig } = state['features/base/config'];
|
|
|
|
const { alwaysVisible } = toolbarConfig || {};
|
2021-09-23 14:39:05 +00:00
|
|
|
const { enabled, visible } = state['features/toolbox'];
|
2021-07-09 12:36:19 +00:00
|
|
|
const participantCount = getParticipantCountWithFake(state);
|
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-09-23 14:39:05 +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.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state from the Redux store.
|
2020-11-04 08:32:06 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function isVideoMuteButtonDisabled(state: IReduxState) {
|
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))
|
|
|
|
|| isLocalVideoTrackDesktop(state);
|
2020-11-04 08:32:06 +00:00
|
|
|
}
|