diff --git a/app/soapbox/features/chats/components/chat-list.tsx b/app/soapbox/features/chats/components/chat-list.tsx index 6965b16a9..a64178b78 100644 --- a/app/soapbox/features/chats/components/chat-list.tsx +++ b/app/soapbox/features/chats/components/chat-list.tsx @@ -1,4 +1,5 @@ -import React from 'react'; +import classNames from 'classnames'; +import React, { useRef, useState } from 'react'; import { useDispatch } from 'react-redux'; import { Virtuoso } from 'react-virtuoso'; @@ -19,8 +20,13 @@ interface IChatList { const ChatList: React.FC = ({ onClickChat, useWindowScroll = false }) => { const dispatch = useDispatch(); + const chatListRef = useRef(null); + const { chatsQuery: { data: chats, isFetching, hasNextPage, fetchNextPage } } = useChats(); + const [isNearBottom, setNearBottom] = useState(false); + const [isNearTop, setNearTop] = useState(true); + const isEmpty = chats?.length === 0; const handleLoadMore = () => { @@ -48,23 +54,41 @@ const ChatList: React.FC = ({ onClickChat, useWindowScroll = false }) }; return ( - - {isEmpty ? renderEmpty() : ( - ( - - )} - components={{ - ScrollSeekPlaceholder: () => , - // Footer: () => hasNextPage ? : null, - EmptyPlaceholder: renderEmpty, - }} - /> - )} - +
+ + {isEmpty ? renderEmpty() : ( + setNearTop(atTop)} + atBottomStateChange={(atBottom) => setNearBottom(atBottom)} + useWindowScroll={useWindowScroll} + data={chats} + endReached={handleLoadMore} + itemContent={(_index, chat) => ( + + )} + components={{ + ScrollSeekPlaceholder: () => , + // Footer: () => hasNextPage ? : null, + EmptyPlaceholder: renderEmpty, + }} + /> + )} + + +
+
+
); };