Fix bug when selecting previous chat

environments/review-chats-g56n7m/deployments/1250
Chewbacca 2022-11-01 10:04:21 -04:00
rodzic b33b32d9dc
commit 929a78641b
1 zmienionych plików z 6 dodań i 1 usunięć

Wyświetl plik

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