bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/audio/audio-graphql/hooks/useToggleVoice.ts

21 lines
577 B
TypeScript
Raw Normal View History

import { useCallback } from 'react';
import { useMutation } from '@apollo/client';
2024-01-29 20:49:40 +08:00
import { USER_SET_MUTED } from '../mutations';
import logger from '/imports/startup/client/logger';
2024-01-29 20:49:40 +08:00
const useToggleVoice = () => {
const [userSetMuted] = useMutation(USER_SET_MUTED);
const toggleVoice = async (userId: string, muted: boolean) => {
try {
await userSetMuted({ variables: { muted, userId } });
} catch (e) {
logger.error('Error on trying to toggle muted');
}
2024-01-29 20:49:40 +08:00
};
return useCallback(toggleVoice, [userSetMuted]);
2024-01-29 20:49:40 +08:00
};
export default useToggleVoice;