-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Expand file tree
/
Copy pathMessageBoxReply.tsx
More file actions
57 lines (51 loc) · 1.69 KB
/
MessageBoxReply.tsx
File metadata and controls
57 lines (51 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import type { IMessage, MessageQuoteAttachment } from '@rocket.chat/core-typings';
import { css } from '@rocket.chat/css-in-js';
import { IconButton, Box, Margins } from '@rocket.chat/fuselage';
import { useUserDisplayName } from '@rocket.chat/ui-client';
import type { ReactElement } from 'react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { QuoteAttachment } from '../../../../components/message/content/attachments/QuoteAttachment';
import AttachmentProvider from '../../../../providers/AttachmentProvider';
import { useChat } from '../../contexts/ChatContext';
const MessageBoxReply = ({ reply }: { reply: IMessage }): ReactElement | null => {
const { t } = useTranslation();
const chat = useChat();
const displayName = useUserDisplayName(reply?.u);
const closeWrapperStyle = css`
position: absolute;
right: 0.5rem;
top: 0.75rem;
`;
return (
<Margins block={4}>
<Box display='flex' position='relative'>
<AttachmentProvider>
<QuoteAttachment
attachment={
{
text: reply.msg,
md: reply.md,
author_name: reply.alias || displayName,
author_icon: `/avatar/${reply.u.username}`,
ts: reply.ts,
attachments: reply?.attachments?.map((obj) => ({ ...obj, collapsed: true })),
collapsed: true,
} as MessageQuoteAttachment
}
/>
</AttachmentProvider>
<Box
className={closeWrapperStyle}
data-mid={reply._id}
onClick={(): void => {
chat?.composer?.dismissQuotedMessage(reply._id);
}}
>
<IconButton mini icon='cross' aria-label={t('Dismiss_quoted_message')} />
</Box>
</Box>
</Margins>
);
};
export default memo(MessageBoxReply);