feat: don’t render moderator icon if everyone is moderator

This commit is contained in:
Bettenbuk Zoltan 2019-05-22 12:00:17 +02:00 committed by Zoltan Bettenbuk
parent 61b66e0edf
commit 5101f69e4e
2 changed files with 28 additions and 1 deletions

View File

@ -260,6 +260,25 @@ function _getAllParticipants(stateful) {
: toState(stateful)['features/base/participants'] || []);
}
/**
* Returns true if all of the meeting participants are moderators.
*
* @param {Object|Function} stateful -Object or function that can be resolved
* to the Redux state.
* @returns {boolean}
*/
export function isEveryoneModerator(stateful: Object | Function) {
const participants = _getAllParticipants(stateful);
for (const participant of participants) {
if (participant.role !== PARTICIPANT_ROLE.MODERATOR) {
return false;
}
}
return true;
}
/**
* Returns true if the current local participant is a moderator in the
* conference.

View File

@ -10,6 +10,7 @@ import { Audio, MEDIA_TYPE } from '../../../base/media';
import {
PARTICIPANT_ROLE,
ParticipantView,
isEveryoneModerator,
isLocalParticipantModerator,
pinParticipant
} from '../../../base/participants';
@ -38,6 +39,11 @@ type Props = {
*/
_audioTrack: Object,
/**
* True if everone in the meeting is moderator.
*/
_isEveryoneModerator: boolean,
/**
* True if the local participant is a moderator.
*/
@ -117,6 +123,7 @@ class Thumbnail extends Component<Props> {
render() {
const {
_audioTrack: audioTrack,
_isEveryoneModerator,
_isModerator,
_largeVideo: largeVideo,
_onClick,
@ -172,7 +179,7 @@ class Thumbnail extends Component<Props> {
{ renderDisplayName && <DisplayNameLabel participantId = { participantId } /> }
{ participant.role === PARTICIPANT_ROLE.MODERATOR
{ !_isEveryoneModerator && participant.role === PARTICIPANT_ROLE.MODERATOR
&& <View style = { styles.moderatorIndicatorContainer }>
<ModeratorIndicator />
</View> }
@ -275,6 +282,7 @@ function _mapStateToProps(state, ownProps) {
return {
_audioTrack: audioTrack,
_isEveryoneModerator: isEveryoneModerator(state),
_isModerator: isLocalParticipantModerator(state),
_largeVideo: largeVideo,
_styles: ColorSchemeRegistry.get(state, 'Thumbnail'),