stream-chat-react
Version:
React components to create chat conversations or livestream style chat
14 lines (13 loc) • 622 B
JavaScript
import { useEffect, useState } from 'react';
import { useChatContext } from '../../../context/ChatContext';
export const useIsChannelMuted = (channel) => {
const { client } = useChatContext('useIsChannelMuted');
const [muted, setMuted] = useState(channel.muteStatus());
useEffect(() => {
const handleEvent = () => setMuted(channel.muteStatus());
client.on('notification.channel_mutes_updated', handleEvent);
return () => client.off('notification.channel_mutes_updated', handleEvent);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [muted]);
return muted;
};