diff --git a/app/soapbox/features/chats/components/chat-page/components/chat-page-new.tsx b/app/soapbox/features/chats/components/chat-page/components/chat-page-new.tsx index 62dda22dd..3c11258ff 100644 --- a/app/soapbox/features/chats/components/chat-page/components/chat-page-new.tsx +++ b/app/soapbox/features/chats/components/chat-page/components/chat-page-new.tsx @@ -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 = () => { 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 (