From fc59cdbdbe7189b51fb147a3a87742619c3cd1e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=8F=D0=BD=20=D0=9C=D0=B8=D0=BD=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 23 Aug 2021 14:53:49 -0500 Subject: [PATCH] fix: Fixes showing awaiting AV moderation after grant moderator. --- react/features/av-moderation/middleware.js | 31 +++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/react/features/av-moderation/middleware.js b/react/features/av-moderation/middleware.js index 748494c4d..43396d022 100644 --- a/react/features/av-moderation/middleware.js +++ b/react/features/av-moderation/middleware.js @@ -5,8 +5,11 @@ import { getConferenceState } from '../base/conference'; import { JitsiConferenceEvents } from '../base/lib-jitsi-meet'; import { MEDIA_TYPE } from '../base/media'; import { + getLocalParticipant, getParticipantDisplayName, + getRemoteParticipants, isLocalParticipantModerator, + isParticipantModerator, PARTICIPANT_UPDATED, raiseHand } from '../base/participants'; @@ -124,19 +127,29 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => { case PARTICIPANT_UPDATED: { const state = getState(); const audioModerationEnabled = isEnabledFromState(MEDIA_TYPE.AUDIO, state); + const participant = action.participant; - // this is handled only by moderators - if (audioModerationEnabled && isLocalParticipantModerator(state)) { - const participant = action.participant; + if (participant && audioModerationEnabled) { + if (isLocalParticipantModerator(state)) { - if (participant.raisedHand) { - // if participant raises hand show notification - !isParticipantApproved(participant.id, MEDIA_TYPE.AUDIO)(state) + // this is handled only by moderators + if (participant.raisedHand) { + // if participant raises hand show notification + !isParticipantApproved(participant.id, MEDIA_TYPE.AUDIO)(state) && dispatch(participantPendingAudio(participant)); - } else { - // if participant lowers hand hide notification - isParticipantPending(participant, MEDIA_TYPE.AUDIO)(state) + } else { + // if participant lowers hand hide notification + isParticipantPending(participant, MEDIA_TYPE.AUDIO)(state) && dispatch(dismissPendingAudioParticipant(participant)); + } + } else if (participant.id === getLocalParticipant(state).id + && /* the new role */ isParticipantModerator(participant)) { + + // this is the granted moderator case + getRemoteParticipants(state).forEach(p => { + p.raisedHand && !isParticipantApproved(p.id, MEDIA_TYPE.AUDIO)(state) + && dispatch(participantPendingAudio(p)); + }); } }