diff --git a/app/soapbox/features/chats/components/chat-message-list.tsx b/app/soapbox/features/chats/components/chat-message-list.tsx index 36ddc799f..2369d1252 100644 --- a/app/soapbox/features/chats/components/chat-message-list.tsx +++ b/app/soapbox/features/chats/components/chat-message-list.tsx @@ -29,8 +29,8 @@ const BIG_EMOJI_LIMIT = 1; const messages = defineMessages({ today: { id: 'chats.dividers.today', defaultMessage: 'Today' }, more: { id: 'chats.actions.more', defaultMessage: 'More' }, - delete: { id: 'chats.actions.delete', defaultMessage: 'Delete message' }, - report: { id: 'chats.actions.report', defaultMessage: 'Report user' }, + delete: { id: 'chats.actions.delete', defaultMessage: 'Delete' }, + copy: { id: 'chats.actions.copy', defaultMessage: 'Copy' }, }); type TimeFormat = 'today' | 'date'; @@ -203,29 +203,31 @@ const ChatMessageList: React.FC = ({ chat, autosize }) => { const renderDivider = (key: React.Key, text: string) => ; - const handleReportUser = (userId: string) => { - return () => { - dispatch(initReportById(userId)); - }; + const handleCopyText = (chatMessage: IChatMessage) => { + if (navigator.clipboard) { + navigator.clipboard.writeText(chatMessage.content); + } }; const renderMessage = (chatMessage: any) => { const isMyMessage = chatMessage.account_id === me; - const menu: Menu = [ - { + const menu: Menu = []; + + if (navigator.clipboard) { + menu.push({ + text: intl.formatMessage(messages.copy), + action: () => handleCopyText(chatMessage), + icon: require('@tabler/icons/copy.svg'), + }); + } + + if (isMyMessage) { + menu.push({ text: intl.formatMessage(messages.delete), action: () => handleDeleteMessage.mutate(chatMessage.id), icon: require('@tabler/icons/trash.svg'), destructive: true, - }, - ]; - - if (chatMessage.account_id !== me) { - menu.push({ - text: intl.formatMessage(messages.report), - action: handleReportUser(chatMessage.account_id), - icon: require('@tabler/icons/flag.svg'), }); } @@ -244,19 +246,29 @@ const ChatMessageList: React.FC = ({ chat, autosize }) => { 'opacity-50': chatMessage.pending, })} > - {isMyMessage ? ( -
+ {menu.length > 0 && ( +
- ) : null} + )}