Merge pull request #20212 from JoVictorNunes/fix-muting-from-indicator

fix(audio): moderators not able to mute users
This commit is contained in:
Ramón Souza 2024-05-15 10:00:18 -03:00 committed by GitHub
commit 6fa1cb7aa5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 20 additions and 28 deletions

View File

@ -63,7 +63,7 @@ interface MuteToggleProps {
muted: boolean;
disabled: boolean;
isAudioLocked: boolean;
toggleMuteMicrophone: (muted: boolean, toggleVoice: (userId?: string | null, muted?: boolean | null) => void) => void;
toggleMuteMicrophone: (muted: boolean, toggleVoice: (userId: string, muted: boolean) => void) => void;
away: boolean;
}

View File

@ -35,7 +35,7 @@ interface MuteToggleProps {
muted: boolean;
disabled: boolean;
isAudioLocked: boolean;
toggleMuteMicrophone: (muted: boolean, toggleVoice: (userId?: string | null, muted?: boolean | null) => void) => void;
toggleMuteMicrophone: (muted: boolean, toggleVoice: (userId: string, muted: boolean) => void) => void;
away: boolean;
}

View File

@ -5,6 +5,7 @@ import Storage from '/imports/ui/services/storage/session';
import logger from '/imports/startup/client/logger';
import AudioManager from '/imports/ui/services/audio-manager';
import VideoService from '/imports/ui/components/video-provider/video-provider-graphql/service';
import Auth from '/imports/ui/services/auth';
const MUTED_KEY = 'muted';
// @ts-ignore - temporary, while meteor exists in the project
@ -42,7 +43,7 @@ export const handleLeaveAudio = (meetingIsBreakout: boolean) => {
export const toggleMuteMicrophone = (
muted: boolean,
toggleVoice: (userId?: string | null, muted?: boolean | null) => void,
toggleVoice: (userId: string, muted: boolean) => void,
) => {
Storage.setItem(MUTED_KEY, !muted);
@ -54,7 +55,7 @@ export const toggleMuteMicrophone = (
},
'microphone unmuted by user',
);
toggleVoice();
toggleVoice(Auth.userID!, false);
} else {
logger.info(
{
@ -63,7 +64,7 @@ export const toggleMuteMicrophone = (
},
'microphone muted by user',
);
toggleVoice();
toggleVoice(Auth.userID!, true);
}
};
@ -98,7 +99,7 @@ export const setSpeakerLevel = (level: number) => {
export const muteAway = (
muted: boolean,
away: boolean,
voiceToggle: (userId?: string | null, muted?: boolean | null) => void,
voiceToggle: (userId: string, muted: boolean) => void,
) => {
const prevAwayMuted = Storage.getItem('prevAwayMuted') || false;
const prevSpeakerLevelValue = Storage.getItem('prevSpeakerLevel') || 1;

View File

@ -1,6 +1,5 @@
import { useCallback } from 'react';
import { useMutation } from '@apollo/client';
import Auth from '/imports/ui/services/auth';
import { USER_SET_MUTED } from '../mutations';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
@ -12,16 +11,8 @@ const useToggleVoice = () => {
},
}));
const toggleVoice = async (userId?: string | null, muted?: boolean | null) => {
let shouldMute = muted;
const userToMute = userId ?? Auth.userID;
if (muted === undefined || muted === null) {
const muted = currentUserData?.voice?.muted;
shouldMute = !muted;
}
userSetMuted({ variables: { muted: shouldMute, userId: userToMute } });
const toggleVoice = async (userId: string, muted: boolean) => {
userSetMuted({ variables: { muted, userId } });
};
return useCallback(toggleVoice, [currentUserData?.voice?.muted]);

View File

@ -28,7 +28,7 @@ const recoverMicState = (toggleVoice) => {
logger.debug({
logCode: 'audio_recover_mic_state',
}, `Audio recover previous mic state: muted = ${muted}`);
toggleVoice(null, muted);
toggleVoice(Auth.userID, muted);
};
const audioEventHandler = (toggleVoice) => (event) => {
@ -83,7 +83,7 @@ const muteMicrophone = (toggleVoice) => {
extraInfo: { logType: 'user_action' },
}, 'User wants to leave conference. Microphone muted');
AudioManager.setSenderTrackEnabled(false);
toggleVoice();
toggleVoice(Auth.userID, true);
}
};
@ -105,13 +105,13 @@ const toggleMuteMicrophone = throttle((toggleVoice) => {
logCode: 'audiomanager_unmute_audio',
extraInfo: { logType: 'user_action' },
}, 'microphone unmuted by user');
toggleVoice();
toggleVoice(Auth.userID, false);
} else {
logger.info({
logCode: 'audiomanager_mute_audio',
extraInfo: { logType: 'user_action' },
}, 'microphone muted by user');
toggleVoice();
toggleVoice(Auth.userID, true);
}
}, TOGGLE_MUTE_THROTTLE_TIME);

View File

@ -58,7 +58,7 @@ interface TalkingIndicatorProps {
isBreakout: boolean;
moreThanMaxIndicators: boolean;
isModerator: boolean;
toggleVoice: (userId?: string | null, muted?: boolean | null) => void;
toggleVoice: (userId: string, muted: boolean) => void;
}
const TalkingIndicator: React.FC<TalkingIndicatorProps> = ({

View File

@ -9,10 +9,10 @@ export const muteUser = debounce(
muted: boolean | undefined,
isBreakout: boolean,
isModerator: boolean,
toggleVoice: (userId?: string | null, muted?: string | null) => void,
toggleVoice: (userId: string, muted: boolean) => void,
) => {
if (!isModerator || isBreakout || muted) return null;
toggleVoice(id);
toggleVoice(id, true);
return null;
},
);

View File

@ -409,7 +409,7 @@ const UserActions: React.FC<UserActionsProps> = ({
key: 'mute',
label: intl.formatMessage(messages.MuteUserAudioLabel),
onClick: () => {
toggleVoice(user.userId, voiceToggle);
toggleVoice(user.userId, true, voiceToggle);
setOpenUserAction(null);
},
icon: 'mute',
@ -421,7 +421,7 @@ const UserActions: React.FC<UserActionsProps> = ({
key: 'unmute',
label: intl.formatMessage(messages.UnmuteUserAudioLabel),
onClick: () => {
toggleVoice(user.userId, voiceToggle);
toggleVoice(user.userId, false, voiceToggle);
setOpenUserAction(null);
},
icon: 'unmute',

View File

@ -124,11 +124,11 @@ export const isVideoPinEnabledForCurrentUser = (
// so this code is duplicated from the old userlist service
// session for chats the current user started
export const toggleVoice = (userId: string, voiceToggle: (userId?: string | null, muted?: boolean | null) => void) => {
export const toggleVoice = (userId: string, muted: boolean, voiceToggle: (userId: string, muted: boolean) => void) => {
if (userId === Auth.userID) {
AudioService.toggleMuteMicrophone(voiceToggle);
} else {
voiceToggle(userId);
voiceToggle(userId, muted);
logger.info({
logCode: 'usermenu_option_mute_toggle_audio',
extraInfo: { logType: 'moderator_action', userId },