File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
package/src/components/ChannelPreview Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 1- import React from 'react' ;
1+ import React , { useEffect , useState } from 'react' ;
22import { StyleSheet , View } from 'react-native' ;
33import { TouchableOpacity } from 'react-native-gesture-handler' ;
44
@@ -17,6 +17,7 @@ import {
1717 ChannelsContextValue ,
1818 useChannelsContext ,
1919} from '../../contexts/channelsContext/ChannelsContext' ;
20+ import { useChatContext } from '../../contexts/chatContext/ChatContext' ;
2021import { useTheme } from '../../contexts/themeContext/ThemeContext' ;
2122import type { DefaultStreamChatGenerics } from '../../types/types' ;
2223import { vw } from '../../utils/utils' ;
@@ -127,12 +128,21 @@ const ChannelPreviewMessengerWithContext = <
127128 } ,
128129 } = useTheme ( ) ;
129130
131+ const { client } = useChatContext < StreamChatGenerics > ( ) ;
132+
130133 const displayName = useChannelPreviewDisplayName (
131134 channel ,
132135 Math . floor ( maxWidth / ( ( title . fontSize || styles . title . fontSize ) / 2 ) ) ,
133136 ) ;
134137
135- const isChannelMuted = channel . muteStatus ( ) . muted ;
138+ const [ isChannelMuted , setIsChannelMuted ] = useState ( ( ) => channel . muteStatus ( ) . muted ) ;
139+
140+ useEffect ( ( ) => {
141+ const handleEvent = ( ) => setIsChannelMuted ( channel . muteStatus ( ) . muted ) ;
142+
143+ client . on ( 'notification.channel_mutes_updated' , handleEvent ) ;
144+ return ( ) => client . off ( 'notification.channel_mutes_updated' , handleEvent ) ;
145+ } , [ ] ) ;
136146
137147 return (
138148 < TouchableOpacity
You can’t perform that action at this time.
0 commit comments