2022-10-19 11:38:38 +00:00
|
|
|
import { IState } from '../app/types';
|
|
|
|
import { IStateful } from '../base/app/types';
|
2020-11-04 08:32:06 +00:00
|
|
|
import { hasAvailableDevices } from '../base/devices';
|
2022-09-27 07:10:28 +00:00
|
|
|
import { TOOLBOX_ALWAYS_VISIBLE, TOOLBOX_ENABLED, getFeatureFlag } from '../base/flags';
|
2021-07-09 12:36:19 +00:00
|
|
|
import { getParticipantCountWithFake } from '../base/participants';
|
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
|
|
|
|
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-19 11:38:38 +00:00
|
|
|
* @param {IState} state - The state from the Redux store.
|
2022-01-05 20:27:42 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-19 11:38:38 +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 || 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-19 11:38:38 +00:00
|
|
|
* @param {IState} state - The state from the Redux store.
|
2020-11-04 08:32:06 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-19 11:38:38 +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))
|
|
|
|
|| isLocalVideoTrackDesktop(state);
|
2020-11-04 08:32:06 +00:00
|
|
|
}
|