Keep fresh messages
This commit is contained in:
parent
a2540cb0d0
commit
51c01bfc04
3 changed files with 5 additions and 6 deletions
|
@ -62,14 +62,12 @@ const timeChange = (prev: IChatMessage, curr: IChatMessage): TimeFormat | null =
|
|||
interface IChatMessageList {
|
||||
/** Chat the messages are being rendered from. */
|
||||
chat: IChat,
|
||||
/** Whether to make the chatbox fill the height of the screen. */
|
||||
autosize?: boolean,
|
||||
}
|
||||
|
||||
const START_INDEX = 10000;
|
||||
|
||||
/** Scrollable list of chat messages. */
|
||||
const ChatMessageList: React.FC<IChatMessageList> = ({ chat, autosize }) => {
|
||||
const ChatMessageList: React.FC<IChatMessageList> = ({ chat }) => {
|
||||
const intl = useIntl();
|
||||
const dispatch = useAppDispatch();
|
||||
const account = useOwnAccount();
|
||||
|
|
|
@ -17,7 +17,6 @@ import ChatMessageList from './chat-message-list';
|
|||
|
||||
interface ChatInterface {
|
||||
chat: IChat,
|
||||
autosize?: boolean,
|
||||
inputRef?: MutableRefObject<HTMLTextAreaElement | null>,
|
||||
className?: string,
|
||||
}
|
||||
|
@ -26,7 +25,7 @@ interface ChatInterface {
|
|||
* Chat UI with just the messages and textarea.
|
||||
* Reused between floating desktop chats and fullscreen/mobile chats.
|
||||
*/
|
||||
const Chat: React.FC<ChatInterface> = ({ chat, autosize, inputRef, className }) => {
|
||||
const Chat: React.FC<ChatInterface> = ({ chat, inputRef, className }) => {
|
||||
const account = useOwnAccount();
|
||||
|
||||
const { createChatMessage, acceptChat } = useChatActions(chat.id);
|
||||
|
@ -205,7 +204,7 @@ const Chat: React.FC<ChatInterface> = ({ chat, autosize, inputRef, className })
|
|||
return (
|
||||
<Stack className={classNames('overflow-hidden flex flex-grow', className)} onMouseOver={handleMouseOver}>
|
||||
<div className='flex-grow h-full overflow-hidden flex justify-center'>
|
||||
<ChatMessageList chat={chat} autosize />
|
||||
<ChatMessageList chat={chat} />
|
||||
</div>
|
||||
|
||||
<ChatComposer
|
||||
|
|
|
@ -104,6 +104,8 @@ const useChatMessages = (chat: IChat) => {
|
|||
|
||||
const queryInfo = useInfiniteQuery(ChatKeys.chatMessages(chat.id), ({ pageParam }) => getChatMessages(chat.id, pageParam), {
|
||||
enabled: !isBlocked,
|
||||
cacheTime: 0,
|
||||
staleTime: 0,
|
||||
getNextPageParam: (config) => {
|
||||
if (config.hasMore) {
|
||||
return { link: config.link };
|
||||
|
|
Loading…
Reference in a new issue