import React from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { useHistory } from 'react-router-dom'; import { blockAccount } from 'soapbox/actions/accounts'; import { launchChat } from 'soapbox/actions/chats'; import { openModal } from 'soapbox/actions/modals'; import { initReport } from 'soapbox/actions/reports'; import AccountSearch from 'soapbox/components/account_search'; import List, { ListItem } from 'soapbox/components/list'; import { Avatar, Card, CardTitle, Divider, HStack, Icon, IconButton, Menu, MenuButton, MenuItem, MenuList, Stack, Text, Toggle } from 'soapbox/components/ui'; import VerificationBadge from 'soapbox/components/verification_badge'; import { useChatContext } from 'soapbox/contexts/chat-context'; import { useAppDispatch } from 'soapbox/hooks'; import { useChat, useChatSilences } from 'soapbox/queries/chats'; import Chat from './chat'; import ChatList from './chat-list'; const messages = defineMessages({ title: { id: 'column.chats', defaultMessage: 'Messages' }, searchPlaceholder: { id: 'chats.search_placeholder', defaultMessage: 'Start a chat with…' }, }); const ChatPage = () => { const intl = useIntl(); const dispatch = useAppDispatch(); const history = useHistory(); const { isSilenced, handleSilence } = useChatSilences(); const { chat, setChat } = useChatContext(); const { deleteChat } = useChat(chat?.id as string); const handleSuggestion = (accountId: string) => { dispatch(launchChat(accountId, history, true)); }; const handleClickChat = (chat: any) => { // history.push(`/chats/${chat.id}`); setChat(chat); }; const handleBlockUser = () => { dispatch(openModal('CONFIRM', { heading: `Block @${chat?.account.acct}`, message: 'Blocking will prevent this profile from direct messaging you and viewing your content. You can unblock later.', confirm: 'Block', confirmationTheme: 'primary', onConfirm: () => dispatch(blockAccount(chat?.account.id as string)), })); }; const handleLeaveChat = () => { dispatch(openModal('CONFIRM', { heading: 'Leave Chat', message: 'Are you sure you want to leave this chat? This conversation will be removed from your inbox.', confirm: 'Leave Chat', confirmationTheme: 'primary', onConfirm: () => { deleteChat.mutate(); }, })); }; const handleReportChat = () => { dispatch(initReport(chat?.account as any)); }; return (
{chat && (
{chat.account?.display_name || `@${chat.account.username}`} {!chat.account?.verified && }
{chat.account.acct}
{chat.account.display_name} @{chat.account.acct}
Block @{chat.account.acct}
Report @{chat.account.acct}
Leave chat
)}
); }; export default ChatPage;