Fix bug when selecting previous chat

environments/review-chats-g56n7m/deployments/1250
Chewbacca 2 years ago
parent b33b32d9dc
commit 929a78641b

@ -4,7 +4,9 @@ import { useHistory } from 'react-router-dom';
import AccountSearch from 'soapbox/components/account_search';
import { CardTitle, HStack, Stack, Text } from 'soapbox/components/ui';
import { useChats } from 'soapbox/queries/chats';
import { useChatContext } from 'soapbox/contexts/chat-context';
import { ChatKeys, useChats } from 'soapbox/queries/chats';
import { queryClient } from 'soapbox/queries/client';
interface IChatPageNew {
}
@ -12,11 +14,14 @@ interface IChatPageNew {
/** New message form to create a chat. */
const ChatPageNew: React.FC<IChatPageNew> = () => {
const history = useHistory();
const { setChat } = useChatContext();
const { getOrCreateChatByAccountId } = useChats();
const handleAccountSelected = async (accountId: string) => {
const { data } = await getOrCreateChatByAccountId(accountId);
setChat(data);
history.push(`/chats/${data.id}`);
queryClient.invalidateQueries(ChatKeys.chatSearch());
};
return (

Loading…
Cancel
Save