ChatPageNew: support account search to start a new chat
This commit is contained in:
parent
acdd999c5c
commit
f8199ab701
1 changed files with 15 additions and 0 deletions
|
@ -1,15 +1,30 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
|
import AccountSearch from 'soapbox/components/account_search';
|
||||||
import { CardTitle, Stack } from 'soapbox/components/ui';
|
import { CardTitle, Stack } from 'soapbox/components/ui';
|
||||||
|
import { useChats } from 'soapbox/queries/chats';
|
||||||
|
|
||||||
interface IChatPageNew {
|
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 { getOrCreateChatByAccountId } = useChats();
|
||||||
|
|
||||||
|
const handleAccountSelected = async (accountId: string) => {
|
||||||
|
const { data } = await getOrCreateChatByAccountId(accountId);
|
||||||
|
history.push(`/chats/${data.id}`);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className='h-full p-6 space-y-8'>
|
<Stack className='h-full p-6 space-y-8'>
|
||||||
<CardTitle title='New Message' />
|
<CardTitle title='New Message' />
|
||||||
|
|
||||||
|
<AccountSearch
|
||||||
|
onSelected={handleAccountSelected}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue