11import React , { useCallback , useEffect , useMemo , useState } from 'react' ;
22
33import { ReplyType } from '@sendbird/chat/message' ;
4- import { useGroupChannelMessages } from '@sendbird/uikit-chat-hooks' ;
54import { Box } from '@sendbird/uikit-react-native-foundation' ;
5+ import { useGroupChannelMessages } from '@sendbird/uikit-tools' ;
66import {
77 NOOP ,
88 PASS ,
99 SendbirdFileMessage ,
1010 SendbirdGroupChannel ,
1111 SendbirdUserMessage ,
12+ confirmAndMarkAsRead ,
1213 messageComparator ,
1314 useFreshCallback ,
1415 useIIFE ,
@@ -75,8 +76,8 @@ const createGroupChannelFragment = (initModule?: Partial<GroupChannelModule>): G
7576 messages,
7677 newMessages,
7778 resetNewMessages,
78- next ,
79- prev ,
79+ loadNext ,
80+ loadPrevious ,
8081 hasNext,
8182 sendFileMessage,
8283 sendUserMessage,
@@ -85,20 +86,21 @@ const createGroupChannelFragment = (initModule?: Partial<GroupChannelModule>): G
8586 resendMessage,
8687 deleteMessage,
8788 resetWithStartingPoint,
88- } = useGroupChannelMessages ( sdk , channel , currentUser ?. userId , {
89+ } = useGroupChannelMessages ( sdk , channel , {
8990 shouldCountNewMessages : ( ) => scrolledAwayFromBottomRef . current ,
9091 onMessagesReceived ( messages ) {
9192 groupChannelPubSub . publish ( { type : 'MESSAGES_RECEIVED' , data : { messages } } ) ;
9293 } ,
9394 onMessagesUpdated ( messages ) {
9495 groupChannelPubSub . publish ( { type : 'MESSAGES_UPDATED' , data : { messages } } ) ;
9596 } ,
97+ onChannelDeleted,
98+ onCurrentUserBanned : onChannelDeleted ,
9699 collectionCreator,
97100 sortComparator,
98- onChannelDeleted ,
101+ markAsRead : confirmAndMarkAsRead ,
99102 replyType,
100103 startingPoint : internalSearchItem ?. startingPoint ,
101- enableCollectionWithoutLocalCache : true ,
102104 } ) ;
103105
104106 const onBlurFragment = ( ) => {
@@ -144,12 +146,12 @@ const createGroupChannelFragment = (initModule?: Partial<GroupChannelModule>): G
144146 [ flatListProps ] ,
145147 ) ;
146148
147- const onResetMessageList = useCallback ( ( callback ?: ( ) => void ) => {
148- resetWithStartingPoint ( Number . MAX_SAFE_INTEGER , callback ) ;
149+ const onResetMessageList = useCallback ( async ( ) => {
150+ return await resetWithStartingPoint ( Number . MAX_SAFE_INTEGER ) ;
149151 } , [ ] ) ;
150152
151- const onResetMessageListWithStartingPoint = useCallback ( ( startingPoint : number , callback ?: ( ) => void ) => {
152- resetWithStartingPoint ( startingPoint , callback ) ;
153+ const onResetMessageListWithStartingPoint = useCallback ( async ( startingPoint : number ) => {
154+ return await resetWithStartingPoint ( startingPoint ) ;
153155 } , [ ] ) ;
154156
155157 // Changing the search item will trigger the focus animation on messages.
@@ -224,8 +226,8 @@ const createGroupChannelFragment = (initModule?: Partial<GroupChannelModule>): G
224226 renderMessage = { renderItem }
225227 messages = { messages }
226228 newMessages = { newMessages }
227- onTopReached = { prev }
228- onBottomReached = { next }
229+ onTopReached = { loadPrevious }
230+ onBottomReached = { loadNext }
229231 hasNext = { hasNext }
230232 scrolledAwayFromBottom = { scrolledAwayFromBottom }
231233 onScrolledAwayFromBottom = { onScrolledAwayFromBottom }
0 commit comments