diff --git a/app/soapbox/features/chats/components/chat-page/chat-page.tsx b/app/soapbox/features/chats/components/chat-page/chat-page.tsx index 63af69155..eb3a80b06 100644 --- a/app/soapbox/features/chats/components/chat-page/chat-page.tsx +++ b/app/soapbox/features/chats/components/chat-page/chat-page.tsx @@ -1,194 +1,16 @@ 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, useChatSilence } from 'soapbox/queries/chats'; +import { Card } from 'soapbox/components/ui'; -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…' }, - blockMessage: { id: 'chat_settings.block.message', defaultMessage: 'Blocking will prevent this profile from direct messaging you and viewing your content. You can unblock later.' }, - blockHeading: { id: 'chat_settings.block.heading', defaultMessage: 'Block @{acct}' }, - blockConfirm: { id: 'chat_settings.block.confirm', defaultMessage: 'Block' }, - leaveMessage: { id: 'chat_settings.leave.message', defaultMessage: 'Are you sure you want to leave this chat? This conversation will be removed from your inbox.' }, - leaveHeading: { id: 'chat_settings.leave.heading', defaultMessage: 'Leave Chat' }, - leaveConfirm: { id: 'chat_settings.leave.confirm', defaultMessage: 'Leave Chat' }, - blockUser: { id: 'chat_settings.options.block_user', defaultMessage: 'Block @{acct}' }, - reportUser: { id: 'chat_settings.options.report_user', defaultMessage: 'Report @{acct}' }, - leaveChat: { id: 'chat_settings.options.leave_chat', defaultMessage: 'Leave Chat' }, -}); +import ChatPageMain from './components/chat-page-main'; +import ChatPageSidebar from './components/chat-page-sidebar'; const ChatPage = () => { - const intl = useIntl(); - const dispatch = useAppDispatch(); - const history = useHistory(); - - const { chat, setChat } = useChatContext(); - const { isSilenced, handleSilence } = useChatSilence(chat); - 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: intl.formatMessage(messages.blockHeading, { acct: chat?.account.acct }), - message: intl.formatMessage(messages.blockMessage), - confirm: intl.formatMessage(messages.blockConfirm), - confirmationTheme: 'primary', - onConfirm: () => dispatch(blockAccount(chat?.account.id as string)), - })); - }; - - const handleLeaveChat = () => { - dispatch(openModal('CONFIRM', { - heading: intl.formatMessage(messages.leaveHeading), - message: intl.formatMessage(messages.leaveMessage), - confirm: intl.formatMessage(messages.leaveConfirm), - 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} - - - - - - - - - - - - - - - -
- - {intl.formatMessage(messages.blockUser, { acct: chat.account.acct })} -
-
- - -
- - {intl.formatMessage(messages.reportUser, { acct: chat.account.acct })} -
-
- - -
- - {intl.formatMessage(messages.leaveChat)} -
-
-
-
-
-
-
- -
- -
-
- )} -
+ +
); diff --git a/app/soapbox/features/chats/components/chat-page/components/chat-page-main.tsx b/app/soapbox/features/chats/components/chat-page/components/chat-page-main.tsx new file mode 100644 index 000000000..88c5badce --- /dev/null +++ b/app/soapbox/features/chats/components/chat-page/components/chat-page-main.tsx @@ -0,0 +1,161 @@ +import React from 'react'; +import { defineMessages, useIntl } from 'react-intl'; + +import { blockAccount } from 'soapbox/actions/accounts'; +import { openModal } from 'soapbox/actions/modals'; +import { initReport } from 'soapbox/actions/reports'; +import List, { ListItem } from 'soapbox/components/list'; +import { Avatar, 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, useChatSilence } from 'soapbox/queries/chats'; + +import Chat from '../../chat'; + +const messages = defineMessages({ + blockMessage: { id: 'chat_settings.block.message', defaultMessage: 'Blocking will prevent this profile from direct messaging you and viewing your content. You can unblock later.' }, + blockHeading: { id: 'chat_settings.block.heading', defaultMessage: 'Block @{acct}' }, + blockConfirm: { id: 'chat_settings.block.confirm', defaultMessage: 'Block' }, + leaveMessage: { id: 'chat_settings.leave.message', defaultMessage: 'Are you sure you want to leave this chat? This conversation will be removed from your inbox.' }, + leaveHeading: { id: 'chat_settings.leave.heading', defaultMessage: 'Leave Chat' }, + leaveConfirm: { id: 'chat_settings.leave.confirm', defaultMessage: 'Leave Chat' }, + blockUser: { id: 'chat_settings.options.block_user', defaultMessage: 'Block @{acct}' }, + reportUser: { id: 'chat_settings.options.report_user', defaultMessage: 'Report @{acct}' }, + leaveChat: { id: 'chat_settings.options.leave_chat', defaultMessage: 'Leave Chat' }, +}); + +const ChatPageMain = () => { + const dispatch = useAppDispatch(); + const intl = useIntl(); + + const { chat } = useChatContext(); + const { isSilenced, handleSilence } = useChatSilence(chat); + const { deleteChat } = useChat(chat?.id as string); + + const handleBlockUser = () => { + dispatch(openModal('CONFIRM', { + heading: intl.formatMessage(messages.blockHeading, { acct: chat?.account.acct }), + message: intl.formatMessage(messages.blockMessage), + confirm: intl.formatMessage(messages.blockConfirm), + confirmationTheme: 'primary', + onConfirm: () => dispatch(blockAccount(chat?.account.id as string)), + })); + }; + + const handleLeaveChat = () => { + dispatch(openModal('CONFIRM', { + heading: intl.formatMessage(messages.leaveHeading), + message: intl.formatMessage(messages.leaveMessage), + confirm: intl.formatMessage(messages.leaveConfirm), + 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} + + + + + + + + + + + + + + + +
+ + {intl.formatMessage(messages.blockUser, { acct: chat.account.acct })} +
+
+ + +
+ + {intl.formatMessage(messages.reportUser, { acct: chat.account.acct })} +
+
+ + +
+ + {intl.formatMessage(messages.leaveChat)} +
+
+
+
+
+
+
+ +
+ +
+
+ )} +
+ ); +}; + +export default ChatPageMain; \ No newline at end of file diff --git a/app/soapbox/features/chats/components/chat-page/components/chat-page-sidebar.tsx b/app/soapbox/features/chats/components/chat-page/components/chat-page-sidebar.tsx new file mode 100644 index 000000000..7b2ac5486 --- /dev/null +++ b/app/soapbox/features/chats/components/chat-page/components/chat-page-sidebar.tsx @@ -0,0 +1,52 @@ +import React from 'react'; +import { defineMessages, useIntl } from 'react-intl'; +import { useHistory } from 'react-router-dom'; + +import { launchChat } from 'soapbox/actions/chats'; +import AccountSearch from 'soapbox/components/account_search'; +import { CardTitle, Stack } from 'soapbox/components/ui'; +import { useChatContext } from 'soapbox/contexts/chat-context'; +import { useAppDispatch } from 'soapbox/hooks'; + +import ChatList from '../../chat-list'; + +import type { IChat } from 'soapbox/queries/chats'; + +const messages = defineMessages({ + title: { id: 'column.chats', defaultMessage: 'Messages' }, + searchPlaceholder: { id: 'chats.search_placeholder', defaultMessage: 'Start a chat with…' }, +}); + +const ChatPageSidebar = () => { + const dispatch = useAppDispatch(); + const history = useHistory(); + const intl = useIntl(); + + const { setChat } = useChatContext(); + + const handleSuggestion = (accountId: string) => { + dispatch(launchChat(accountId, history, true)); + }; + + const handleClickChat = (chat: IChat) => setChat(chat); + + return ( + + + + + + + + + + ); +}; + +export default ChatPageSidebar; \ No newline at end of file