Fix bug when selecting previous chat
This commit is contained in:
parent
b33b32d9dc
commit
929a78641b
1 changed files with 6 additions and 1 deletions
|
@ -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…
Reference in a new issue