bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/audio/audio-graphql/hooks/useToggleVoice.ts
João Victor 40fa0eaab3 fix(audio): explicitly pass whcih user to mute
- Do not assume current user to mute when params are nullable
2024-05-10 08:52:01 -03:00

22 lines
629 B
TypeScript

import { useCallback } from 'react';
import { useMutation } from '@apollo/client';
import { USER_SET_MUTED } from '../mutations';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
const useToggleVoice = () => {
const [userSetMuted] = useMutation(USER_SET_MUTED);
const { data: currentUserData } = useCurrentUser((u) => ({
voice: {
muted: u.voice?.muted,
},
}));
const toggleVoice = async (userId: string, muted: boolean) => {
userSetMuted({ variables: { muted, userId } });
};
return useCallback(toggleVoice, [currentUserData?.voice?.muted]);
};
export default useToggleVoice;