Files
jitsi-meet/react/features/toolbox/functions.native.js
Jaya Allamsetty b19e4d76b5 fix(media) dispatch the unmute blocked action irrepective of the muted state.
This fixes an issue where the user muted by focus is able to unmute themselves even when the sender limit has been reached.
2021-12-07 17:13:29 -06:00

89 lines
2.6 KiB
JavaScript

// @flow
import { hasAvailableDevices } from '../base/devices';
import { TOOLBOX_ALWAYS_VISIBLE, getFeatureFlag, TOOLBOX_ENABLED } from '../base/flags';
import { getParticipantCountWithFake } from '../base/participants';
import { toState } from '../base/redux';
import { isLocalVideoTrackDesktop } from '../base/tracks';
export * from './functions.any';
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> {
let buttons = [];
switch (true) {
case width >= WIDTH.FIT_9_ICONS: {
buttons = [ 'togglecamera', 'chat', 'participantspane', 'raisehand', 'tileview' ];
break;
}
case width >= WIDTH.FIT_8_ICONS: {
buttons = [ 'chat', 'togglecamera', 'raisehand', 'tileview' ];
break;
}
case width >= WIDTH.FIT_7_ICONS: {
buttons = [ 'chat', 'togglecamera', 'raisehand' ];
break;
}
case width >= WIDTH.FIT_6_ICONS: {
buttons = [ 'chat', 'togglecamera' ];
break;
}
default: {
buttons = [ 'chat' ];
}
}
return new Set(buttons);
}
/**
* 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) {
const state = toState(stateful);
const { toolbarConfig } = state['features/base/config'];
const { alwaysVisible } = toolbarConfig || {};
const { enabled, visible } = state['features/toolbox'];
const participantCount = getParticipantCountWithFake(state);
const alwaysVisibleFlag = getFeatureFlag(state, TOOLBOX_ALWAYS_VISIBLE, false);
const enabledFlag = getFeatureFlag(state, TOOLBOX_ENABLED, true);
return enabledFlag && enabled
&& (alwaysVisible || visible || participantCount === 1 || alwaysVisibleFlag);
}
/**
* 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) {
const { muted, unmuteBlocked } = state['features/base/media'].video;
return !hasAvailableDevices(state, 'videoInput')
|| (unmuteBlocked && Boolean(muted))
|| isLocalVideoTrackDesktop(state);
}