Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(lobby): Hide enable option if there is a visitor
Hristo Terezov248908f476d3
diff --git a/react/features/lobby/actions.any.ts b/react/features/lobby/actions.any.tsindex f5846b29da..9053d651bd 100644--- a/react/features/lobby/actions.any.ts+++ b/react/features/lobby/actions.any.ts@@ -21,7 +21,8 @@ import {SET_PASSWORD_JOIN_FAILED} from './actionTypes';import { LOBBY_CHAT_INITIALIZED, MODERATOR_IN_CHAT_WITH_LEFT } from './constants';-import { getKnockingParticipants, getLobbyConfig, getLobbyEnabled } from './functions';+import { getKnockingParticipants, getLobbyConfig, getLobbyEnabled, isEnablingLobbyAllowed } from './functions';+import logger from './logger';import { IKnockingParticipant } from './types';/**@@ -243,7 +244,11 @@ export function toggleLobbyMode(enabled: boolean) {const conference = getCurrentConference(getState);if (enabled) {- conference?.enableLobby();+ if (isEnablingLobbyAllowed(getState())) {+ conference?.enableLobby();+ } else {+ logger.info('Ignoring enable lobby request because there are visitors in the call already.');+ }} else {conference?.disableLobby();}diff --git a/react/features/lobby/functions.ts b/react/features/lobby/functions.tsindex 80b1daabf9..9891fdbba9 100644--- a/react/features/lobby/functions.ts+++ b/react/features/lobby/functions.ts@@ -1,5 +1,6 @@import { IReduxState } from '../app/types';import { getCurrentConference } from '../base/conference/functions';+import { getVisitorsCount } from '../visitors/functions';import { IKnockingParticipant } from './types';@@ -92,3 +93,13 @@ export function showLobbyChatButton(return false;};}++/**+ * Returns true if enabling lobby is allowed and false otherwise.+ *+ * @param {IReduxState} state - State object.+ * @returns {boolean}+ */+export function isEnablingLobbyAllowed(state: IReduxState) {+ return getVisitorsCount(state) <= 0;+}diff --git a/react/features/security/components/security-dialog/native/SecurityDialog.tsx b/react/features/security/components/security-dialog/native/SecurityDialog.tsxindex 12073f07a3..5c81b26ec2 100644--- a/react/features/security/components/security-dialog/native/SecurityDialog.tsx+++ b/react/features/security/components/security-dialog/native/SecurityDialog.tsx@@ -22,6 +22,7 @@ import { BUTTON_TYPES } from '../../../../base/ui/constants.native';import { copyText } from '../../../../base/util/copyText.native';import { isInBreakoutRoom } from '../../../../breakout-rooms/functions';import { toggleLobbyMode } from '../../../../lobby/actions.any';+import { isEnablingLobbyAllowed } from '../../../../lobby/functions';import {endRoomLockRequest,unlockRoom@@ -50,6 +51,11 @@ interface IProps {*/_conference?: IJitsiConference;+ /**+ * Whether enabling lobby is allowed or not.+ */+ _isEnablingLobbyAllowed: boolean;+/*** Whether the local user is the moderator.*/@@ -174,11 +180,12 @@ class SecurityDialog extends PureComponent<IProps, IState> {*/_renderLobbyMode() {const {+ _isEnablingLobbyAllowed,_lobbyModeSwitchVisible,t} = this.props;- if (!_lobbyModeSwitchVisible) {+ if (!_lobbyModeSwitchVisible || !_isEnablingLobbyAllowed) {return null;}@@ -509,6 +516,7 @@ function _mapStateToProps(state: IReduxState) {return {_conference: conference,+ _isEnablingLobbyAllowed: isEnablingLobbyAllowed(state),_isModerator: isLocalParticipantModerator(state),_lobbyEnabled: lobbyEnabled,_lobbyModeSwitchVisible:diff --git a/react/features/security/components/security-dialog/web/SecurityDialog.tsx b/react/features/security/components/security-dialog/web/SecurityDialog.tsxindex 8581c5e7e7..23485e8262 100644--- a/react/features/security/components/security-dialog/web/SecurityDialog.tsx+++ b/react/features/security/components/security-dialog/web/SecurityDialog.tsx@@ -9,6 +9,7 @@ import { isLocalParticipantModerator } from '../../../../base/participants/functimport Dialog from '../../../../base/ui/components/web/Dialog';import E2EESection from '../../../../e2ee/components/E2EESection';import LobbySection from '../../../../lobby/components/web/LobbySection';+import { isEnablingLobbyAllowed } from '../../../../lobby/functions';import PasswordSection from './PasswordSection';@@ -40,6 +41,11 @@ interface IProps {*/_disableLobbyPassword?: boolean;+ /**+ * Whether to hide the lobby section.+ */+ _isEnablingLobbyAllowed: boolean;+/*** The value for how the conference is locked (or undefined if not locked)* as defined by room-lock constants.@@ -77,6 +83,7 @@ function SecurityDialog({_canEditPassword,_conference,_disableLobbyPassword,+ _isEnablingLobbyAllowed,_locked,_password,_passwordNumberOfDigits,@@ -97,25 +104,29 @@ function SecurityDialog({ok = {{ hidden: true }}titleKey = 'security.title'><div className = 'security-dialog'>- <LobbySection />- {!_disableLobbyPassword && (- <>- <div className = 'separator-line' />- <PasswordSection- buttonsWithNotifyClick = { _buttonsWithNotifyClick }- canEditPassword = { _canEditPassword }- conference = { _conference }- locked = { _locked }- password = { _password }- passwordEditEnabled = { passwordEditEnabled }- passwordNumberOfDigits = { _passwordNumberOfDigits }- setPassword = { setPassword }- setPasswordEditEnabled = { setPasswordEditEnabled } />- </>- )}+ {+ _isEnablingLobbyAllowed && <LobbySection />+ }+ {+ !_disableLobbyPassword && (+ <>+ { _isEnablingLobbyAllowed && <div className = 'separator-line' /> }+ <PasswordSection+ buttonsWithNotifyClick = { _buttonsWithNotifyClick }+ canEditPassword = { _canEditPassword }+ conference = { _conference }+ locked = { _locked }+ password = { _password }+ passwordEditEnabled = { passwordEditEnabled }+ passwordNumberOfDigits = { _passwordNumberOfDigits }+ setPassword = { setPassword }+ setPasswordEditEnabled = { setPasswordEditEnabled } />+ </>+ )+ }{_showE2ee ? <>- <div className = 'separator-line' />+ { (_isEnablingLobbyAllowed || !_disableLobbyPassword) && <div className = 'separator-line' /> }<E2EESection /></> : null}@@ -145,6 +156,7 @@ function mapStateToProps(state: IReduxState) {buttonsWithNotifyClick} = state['features/base/config'];const { disableLobbyPassword } = getSecurityUiConfig(state);+ const _isEnablingLobbyAllowed = isEnablingLobbyAllowed(state);const showE2ee = Boolean(e2eeSupported) && isLocalParticipantModerator(state);@@ -154,6 +166,7 @@ function mapStateToProps(state: IReduxState) {_conference: conference,_dialIn: state['features/invite'],_disableLobbyPassword: disableLobbyPassword,+ _isEnablingLobbyAllowed,_locked: locked,_password: password,_passwordNumberOfDigits: roomPasswordNumberOfDigits,diff --git a/react/features/visitors/functions.ts b/react/features/visitors/functions.tsindex 51a0429b4a..74fb57852d 100644--- a/react/features/visitors/functions.ts+++ b/react/features/visitors/functions.ts@@ -34,3 +34,14 @@ export function getPromotionRequests(state: IReduxState) {export function iAmVisitor(stateful: IStateful) {return toState(stateful)['features/visitors'].iAmVisitor;}++/**+ * Returns the number of visitors.+ *+ * @param {Function|Object} stateful - The redux store or {@code getState}+ * function.+ * @returns {number} - The number of visitors.+ */+export function getVisitorsCount(stateful: IStateful) {+ return toState(stateful)['features/visitors'].count ?? 0;+}