@@ -53,6 +53,7 @@ import { mergeThemes, useTheme } from '../../contexts/themeContext/ThemeContext'
5353import { ThreadContextValue , useThreadContext } from '../../contexts/threadContext/ThreadContext' ;
5454
5555import { useStableCallback , useStateStore } from '../../hooks' ;
56+ import { ChannelUnreadStateStoreType } from '../../state-store/channel-unread-state' ;
5657import { MessageInputHeightState } from '../../state-store/message-input-height-store' ;
5758import { primitives } from '../../theme' ;
5859import { MessageWrapper } from '../Message/MessageSimple/MessageWrapper' ;
@@ -104,6 +105,10 @@ const messageInputHeightStoreSelector = (state: MessageInputHeightState) => ({
104105 height : state . height ,
105106} ) ;
106107
108+ const channelUnreadStateStoreSelector = ( state : ChannelUnreadStateStoreType ) => ( {
109+ unread_messages : state . channelUnreadState ?. unread_messages ,
110+ } ) ;
111+
107112type MessageFlashListPropsWithContext = Pick <
108113 AttachmentPickerContextValue ,
109114 'closePicker' | 'attachmentPickerStore'
@@ -317,6 +322,11 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
317322 messageInputHeightStoreSelector ,
318323 ) ;
319324
325+ const { unread_messages } = useStateStore (
326+ channelUnreadStateStore . state ,
327+ channelUnreadStateStoreSelector ,
328+ ) ;
329+
320330 const [ hasMoved , setHasMoved ] = useState ( false ) ;
321331 const [ scrollToBottomButtonVisible , setScrollToBottomButtonVisible ] = useState ( false ) ;
322332 const [ isUnreadNotificationOpen , setIsUnreadNotificationOpen ] = useState < boolean > ( false ) ;
@@ -1094,13 +1104,16 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
10941104 < ScrollToBottomButton
10951105 onPress = { goToNewMessages }
10961106 showNotification = { scrollToBottomButtonVisible }
1097- unreadCount = { threadList ? 0 : channel ?. countUnread ( ) }
1107+ unreadCount = { threadList ? 0 : unread_messages }
10981108 />
10991109 </ Animated . View >
11001110 < NetworkDownIndicator />
11011111 { isUnreadNotificationOpen && ! threadList ? (
11021112 < View style = { styles . unreadMessagesNotificationContainer } >
1103- < UnreadMessagesNotification onCloseHandler = { onUnreadNotificationClose } />
1113+ < UnreadMessagesNotification
1114+ onCloseHandler = { onUnreadNotificationClose }
1115+ unreadCount = { unread_messages }
1116+ />
11041117 </ View >
11051118 ) : null }
11061119 </ View >
0 commit comments