@@ -150,7 +150,7 @@ type MessageListPropsWithContext = Pick<
150150 > &
151151 Pick < ChatContextValue , 'client' > &
152152 Pick < ImageGalleryContextValue , 'setMessages' > &
153- Pick < PaginatedMessageListContextValue , 'loadMore' | 'loadMoreRecent' > &
153+ Pick < PaginatedMessageListContextValue , 'loadMore' | 'loadMoreRecent' | 'hasMore' > &
154154 Pick <
155155 MessagesContextValue ,
156156 | 'DateHeader'
@@ -165,7 +165,7 @@ type MessageListPropsWithContext = Pick<
165165 > &
166166 Pick <
167167 ThreadContextValue ,
168- 'loadMoreRecentThread' | 'loadMoreThread' | 'thread' | 'threadInstance'
168+ 'loadMoreRecentThread' | 'loadMoreThread' | 'threadHasMore' | ' thread' | 'threadInstance'
169169 > & {
170170 /**
171171 * Besides existing (default) UX behavior of underlying FlatList of MessageList component, if you want
@@ -297,6 +297,8 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
297297 TypingIndicator,
298298 TypingIndicatorContainer,
299299 UnreadMessagesNotification,
300+ hasMore,
301+ threadHasMore,
300302 } = props ;
301303 const [ isUnreadNotificationOpen , setIsUnreadNotificationOpen ] = useState < boolean > ( false ) ;
302304 const { theme } = useTheme ( ) ;
@@ -858,8 +860,12 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
858860 * 3. If the call to `loadMoreRecent` is in progress, we wait for it to finish to make sure scroll doesn't jump.
859861 */
860862 const maybeCallOnEndReached = useStableCallback ( async ( ) => {
863+ const shouldQuery = ( threadList && threadHasMore ) || ( ! threadList && hasMore ) ;
861864 // If onEndReached has already been called for given messageList length, then ignore.
862- if ( processedMessageList ?. length && onEndReachedTracker . current [ processedMessageList . length ] ) {
865+ if (
866+ ( processedMessageList ?. length && onEndReachedTracker . current [ processedMessageList . length ] ) ||
867+ ! shouldQuery
868+ ) {
863869 return ;
864870 }
865871
@@ -1301,8 +1307,8 @@ export const MessageList = (props: MessageListProps) => {
13011307 TypingIndicatorContainer,
13021308 UnreadMessagesNotification,
13031309 } = useMessagesContext ( ) ;
1304- const { loadMore, loadMoreRecent } = usePaginatedMessageListContext ( ) ;
1305- const { loadMoreRecentThread, loadMoreThread, thread, threadInstance } = useThreadContext ( ) ;
1310+ const { loadMore, loadMoreRecent, hasMore } = usePaginatedMessageListContext ( ) ;
1311+ const { loadMoreRecentThread, loadMoreThread, threadHasMore , thread, threadInstance } = useThreadContext ( ) ;
13061312
13071313 return (
13081314 < MessageListWithContext
@@ -1356,6 +1362,8 @@ export const MessageList = (props: MessageListProps) => {
13561362 TypingIndicator,
13571363 TypingIndicatorContainer,
13581364 UnreadMessagesNotification,
1365+ hasMore,
1366+ threadHasMore,
13591367 } }
13601368 { ...props }
13611369 noGroupByUser = { ! enableMessageGroupingByUser || props . noGroupByUser }
0 commit comments