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
feat(participants): add isLocalParticipantModerator utility method
Zoltan Bettenbukb57dad576ae5
diff --git a/react/features/base/participants/functions.js b/react/features/base/participants/functions.jsindex 7392a55f34..64957fca34 100644--- a/react/features/base/participants/functions.js+++ b/react/features/base/participants/functions.js@@ -5,7 +5,8 @@ import { toState } from '../redux';import {DEFAULT_AVATAR_RELATIVE_PATH,- LOCAL_PARTICIPANT_DEFAULT_ID+ LOCAL_PARTICIPANT_DEFAULT_ID,+ PARTICIPANT_ROLE} from './constants';declare var config: Object;@@ -224,3 +225,28 @@ function _getAllParticipants(stateful) {? stateful: toState(stateful)['features/base/participants'] || []);}++/**+ * Returns true if the current local participant is a moderator in the+ * conference.+ *+ * @param {Object|Function} stateful - Object or function that can be resolved+ * to the Redux state.+ * @returns {boolean}+ */+export function isLocalParticipantModerator(stateful: Object | Function) {+ const state = toState(stateful);+ const localParticipant = getLocalParticipant(state);++ if (!localParticipant) {+ return false;+ }++ const isModerator = localParticipant.role === PARTICIPANT_ROLE.MODERATOR;++ if (state['features/base/config'].enableUserRolesBasedOnToken) {+ return isModerator && !state['features/base/jwt'].isGuest;+ }++ return isModerator;+}diff --git a/react/features/invite/components/info-dialog/InfoDialog.web.js b/react/features/invite/components/info-dialog/InfoDialog.web.jsindex f0f0ac795a..97c83a7082 100644--- a/react/features/invite/components/info-dialog/InfoDialog.web.js+++ b/react/features/invite/components/info-dialog/InfoDialog.web.js@@ -5,10 +5,7 @@ import { connect } from 'react-redux';import { setPassword } from '../../../base/conference';import { getInviteURL } from '../../../base/connection';import { translate } from '../../../base/i18n';-import {- PARTICIPANT_ROLE,- getLocalParticipant-} from '../../../base/participants';+import { isLocalParticipantModerator } from '../../../base/participants';import DialInNumber from './DialInNumber';import PasswordForm from './PasswordForm';@@ -553,18 +550,9 @@ function _mapStateToProps(state) {password,room} = state['features/base/conference'];- const isModerator- = getLocalParticipant(state).role === PARTICIPANT_ROLE.MODERATOR;- let canEditPassword;-- if (state['features/base/config'].enableUserRolesBasedOnToken) {- canEditPassword = isModerator && !state['features/base/jwt'].isGuest;- } else {- canEditPassword = isModerator;- }return {- _canEditPassword: canEditPassword,+ _canEditPassword: isLocalParticipantModerator(state),_conference: conference,_conferenceName: room,_inviteURL: getInviteURL(state),diff --git a/react/features/invite/functions.js b/react/features/invite/functions.jsindex 3faa4b95b7..3ae3447d09 100644--- a/react/features/invite/functions.js+++ b/react/features/invite/functions.js@@ -1,7 +1,7 @@// @flowimport { getAppProp } from '../app';-import { getLocalParticipant, PARTICIPANT_ROLE } from '../base/participants';+import { isLocalParticipantModerator } from '../base/participants';import { doGetJSON } from '../base/util';declare var $: Function;@@ -300,14 +300,10 @@ export function isAddPeopleEnabled(state: Object): boolean {* @returns {boolean} Indication of whether dial out is currently enabled.*/export function isDialOutEnabled(state: Object): boolean {- const participant = getLocalParticipant(state);const { conference } = state['features/base/conference'];- const { isGuest } = state['features/base/jwt'];- const { enableUserRolesBasedOnToken } = state['features/base/config'];- let dialOutEnabled- = participant && participant.role === PARTICIPANT_ROLE.MODERATOR- && conference && conference.isSIPCallingSupported()- && (!enableUserRolesBasedOnToken || !isGuest);+ let dialOutEnabled = isLocalParticipantModerator(state)+ && conference+ && conference.isSIPCallingSupported();if (dialOutEnabled) {// XXX The mobile/react-native app is capable of disabling of dial-out.