feat(participants): add isLocalParticipantModerator utility method
This commit is contained in:
parent
494e8eb8d9
commit
b57dad576a
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// @flow
|
||||
|
||||
import { 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.
|
||||
|
|
Loading…
Reference in New Issue