Browse Source

fix(av-moderation) Update function that calculates quick action button

master
robertpin 3 years ago
parent
commit
8fd7b10f06

+ 2
- 16
react/features/participants-pane/components/web/MeetingParticipantItem.js View File

@@ -2,7 +2,6 @@
2 2
 
3 3
 import React, { useCallback, useEffect, useState } from 'react';
4 4
 
5
-import { isSupported } from '../../../av-moderation/functions';
6 5
 import { translate } from '../../../base/i18n';
7 6
 import { JitsiTrackEvents } from '../../../base/lib-jitsi-meet';
8 7
 import { MEDIA_TYPE } from '../../../base/media';
@@ -10,7 +9,6 @@ import {
10 9
     getLocalParticipant,
11 10
     getParticipantByIdOrUndefined,
12 11
     getParticipantDisplayName,
13
-    isLocalParticipantModerator,
14 12
     isParticipantModerator
15 13
 } from '../../../base/participants';
16 14
 import { connect } from '../../../base/redux';
@@ -20,7 +18,7 @@ import {
20 18
     isParticipantAudioMuted,
21 19
     isParticipantVideoMuted
22 20
 } from '../../../base/tracks';
23
-import { ACTION_TRIGGER, type MediaState, MEDIA_STATE, QUICK_ACTION_BUTTON } from '../../constants';
21
+import { ACTION_TRIGGER, type MediaState, MEDIA_STATE } from '../../constants';
24 22
 import {
25 23
     getParticipantAudioMediaState,
26 24
     getParticipantVideoMediaState,
@@ -174,9 +172,7 @@ function MeetingParticipantItem({
174 172
     _audioTrack,
175 173
     _disableModeratorIndicator,
176 174
     _displayName,
177
-    _isModerationSupported,
178 175
     _local,
179
-    _localModerator,
180 176
     _localVideoOwner,
181 177
     _participant,
182 178
     _participantID,
@@ -234,12 +230,6 @@ function MeetingParticipantItem({
234 230
         askToUnmuteText = t('participantsPane.actions.allowVideo');
235 231
     }
236 232
 
237
-    const buttonType = _isModerationSupported
238
-        ? _localModerator && _audioMediaState !== MEDIA_STATE.UNMUTED
239
-            ? QUICK_ACTION_BUTTON.ASK_TO_UNMUTE
240
-            : _quickActionButtonType
241
-        : '';
242
-
243 233
     return (
244 234
         <ParticipantItem
245 235
             actionsTrigger = { ACTION_TRIGGER.HOVER }
@@ -261,7 +251,7 @@ function MeetingParticipantItem({
261 251
                 && <>
262 252
                     <ParticipantQuickAction
263 253
                         askUnmuteText = { askToUnmuteText }
264
-                        buttonType = { buttonType }
254
+                        buttonType = { _quickActionButtonType }
265 255
                         muteAudio = { muteAudio }
266 256
                         muteParticipantButtonText = { muteParticipantButtonText }
267 257
                         participantID = { _participantID } />
@@ -307,16 +297,12 @@ function _mapStateToProps(state, ownProps): Object {
307 297
 
308 298
     const { disableModeratorIndicator } = state['features/base/config'];
309 299
 
310
-    const _localModerator = isLocalParticipantModerator(state);
311
-
312 300
     return {
313 301
         _audioMediaState,
314 302
         _audioTrack,
315 303
         _disableModeratorIndicator: disableModeratorIndicator,
316 304
         _displayName: getParticipantDisplayName(state, participant?.id),
317
-        _isModerationSupported: isSupported()(state),
318 305
         _local: Boolean(participant?.local),
319
-        _localModerator,
320 306
         _localVideoOwner: Boolean(ownerId === localParticipantId),
321 307
         _participant: participant,
322 308
         _participantID: participant?.id,

+ 5
- 4
react/features/participants-pane/functions.js View File

@@ -3,7 +3,8 @@
3 3
 import {
4 4
     isParticipantApproved,
5 5
     isEnabledFromState,
6
-    isLocalParticipantApprovedFromState
6
+    isLocalParticipantApprovedFromState,
7
+    isSupported
7 8
 } from '../av-moderation/functions';
8 9
 import { getFeatureFlag, INVITE_ENABLED } from '../base/flags';
9 10
 import { MEDIA_TYPE, type MediaType } from '../base/media/constants';
@@ -164,12 +165,12 @@ export const getParticipantsPaneOpen = (state: Object) => Boolean(getState(state
164 165
 export function getQuickActionButtonType(participant: Object, isAudioMuted: Boolean, state: Object) {
165 166
     // handled only by moderators
166 167
     if (isLocalParticipantModerator(state)) {
167
-        if (isForceMuted(participant, MEDIA_TYPE.AUDIO, state) || isForceMuted(participant, MEDIA_TYPE.VIDEO, state)) {
168
-            return QUICK_ACTION_BUTTON.ASK_TO_UNMUTE;
169
-        }
170 168
         if (!isAudioMuted) {
171 169
             return QUICK_ACTION_BUTTON.MUTE;
172 170
         }
171
+        if (isSupported()(state)) {
172
+            return QUICK_ACTION_BUTTON.ASK_TO_UNMUTE;
173
+        }
173 174
     }
174 175
 
175 176
     return QUICK_ACTION_BUTTON.NONE;

Loading…
Cancel
Save