Skip to content

Commit

Permalink
fix: hmr issue due to disconnect (#2169)
Browse files Browse the repository at this point in the history
  • Loading branch information
santhoshvai committed Jul 5, 2023
1 parent ec515b6 commit 9c8150f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions package/src/components/ChannelPreview/ChannelPreviewMessenger.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import { StyleSheet, View } from 'react-native';
import { TouchableOpacity } from 'react-native-gesture-handler';

Expand All @@ -17,6 +17,7 @@ import {
ChannelsContextValue,
useChannelsContext,
} from '../../contexts/channelsContext/ChannelsContext';
import { useChatContext } from '../../contexts/chatContext/ChatContext';
import { useTheme } from '../../contexts/themeContext/ThemeContext';
import type { DefaultStreamChatGenerics } from '../../types/types';
import { vw } from '../../utils/utils';
Expand Down Expand Up @@ -127,12 +128,21 @@ const ChannelPreviewMessengerWithContext = <
},
} = useTheme();

const { client } = useChatContext<StreamChatGenerics>();

const displayName = useChannelPreviewDisplayName(
channel,
Math.floor(maxWidth / ((title.fontSize || styles.title.fontSize) / 2)),
);

const isChannelMuted = channel.muteStatus().muted;
const [isChannelMuted, setIsChannelMuted] = useState(() => channel.muteStatus().muted);

useEffect(() => {
const handleEvent = () => setIsChannelMuted(channel.muteStatus().muted);

client.on('notification.channel_mutes_updated', handleEvent);
return () => client.off('notification.channel_mutes_updated', handleEvent);
}, []);

return (
<TouchableOpacity
Expand Down

0 comments on commit 9c8150f

Please sign in to comment.