diff --git a/packages/status-react/src/routes/chat/components/chat-message/message-reply.tsx b/packages/status-react/src/routes/chat/components/chat-message/message-reply.tsx index a2b6b18f..5c6bec0c 100644 --- a/packages/status-react/src/routes/chat/components/chat-message/message-reply.tsx +++ b/packages/status-react/src/routes/chat/components/chat-message/message-reply.tsx @@ -1,38 +1,63 @@ import React from 'react' +import { useMatch } from 'react-router-dom' + +import { useProtocol } from '~/src/protocol' import { styled } from '~/src/styles/config' import { Avatar, Box, Flex, Image, Text } from '~/src/system' -import type { Reply } from '~/src/protocol/use-messages' - interface Props { - reply: Reply + messageId: string } export const MessageReply = (props: Props) => { - const { reply } = props + const { messageId } = props - const { contact } = reply + const { client } = useProtocol() + + // TODO: use protocol hook + const { params } = useMatch(':id')! // eslint-disable-line @typescript-eslint/no-non-null-assertion + const message = client.community.getChat(params.id).getMessage(messageId) + + if (!message) { + return ( + + + Message not available. + + + ) + } + + const { contentType, text, sender } = message + const { username } = client.community.getMember(sender) return ( - + - {contact.name} + {username} - {reply.type === 'text' && ( + {contentType === 'TEXT_PLAIN' && ( - {reply.text} + {text} )} - {reply.type === 'image' && ( + {contentType === 'EMOJI' && ( + + + {text} + + + )} + {contentType === 'IMAGE' && ( { /> )} - {reply.type === 'image-text' && ( - - - {reply.text} - - message - - )} ) }