Keep fresh messages

revert-fa4bd20d
Chewbacca 2022-11-03 13:55:33 -04:00
rodzic a2540cb0d0
commit 51c01bfc04
3 zmienionych plików z 5 dodań i 6 usunięć

Wyświetl plik

@ -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();

Wyświetl plik

@ -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

Wyświetl plik

@ -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 };