File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
package/src/components/ChannelPreview/hooks Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -17,11 +17,25 @@ export const useIsChannelMuted = (channel: Channel) => {
1717
1818 useEffect ( ( ) => {
1919 const handleEvent = ( ) => {
20+ const newMuteStatus = channel . muteStatus ( ) ;
21+ if (
22+ newMuteStatus . muted === muted . muted &&
23+ newMuteStatus . createdAt ?. getTime ( ) === muted . createdAt ?. getTime ( ) &&
24+ newMuteStatus . expiresAt ?. getTime ( ) === muted . expiresAt ?. getTime ( )
25+ ) {
26+ return ;
27+ }
28+
2029 setMuted ( channel . muteStatus ( ) ) ;
2130 } ;
2231
23- client . on ( 'notification.channel_mutes_updated' , handleEvent ) ;
24- return ( ) => client . off ( 'notification.channel_mutes_updated' , handleEvent ) ;
32+ const listeners = [
33+ client . on ( 'notification.channel_mutes_updated' , handleEvent ) ,
34+ client . on ( 'health.check' , handleEvent ) ,
35+ ] ;
36+ return ( ) => {
37+ listeners . forEach ( ( listener ) => listener . unsubscribe ( ) ) ;
38+ } ;
2539 } , [ channel , client , muted ] ) ;
2640
2741 return muted ?? defaultMuteStatus ;
You can’t perform that action at this time.
0 commit comments