-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add message render component
- Loading branch information
Filipe Marins
committed
Apr 26, 2022
1 parent
42e0e4a
commit ee3d2c8
Showing
4 changed files
with
45 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
apps/meteor/client/views/room/MessageList/components/MessageRender.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* eslint-disable complexity */ | ||
import { IMessage } from '@rocket.chat/core-typings'; | ||
import React, { FC, memo } from 'react'; | ||
|
||
import { isE2EEMessage } from '../../../../../lib/isE2EEMessage'; | ||
import MessageBodyRender from '../../../../components/Message/MessageBodyRender'; | ||
import { useMessageActions } from '../../contexts/MessageContext'; | ||
import EncryptedMessageRender from './EncryptedMessageRender'; | ||
|
||
const MessageRender: FC<{ message: IMessage; disableBigEmoji?: boolean }> = ({ message, disableBigEmoji = false }) => { | ||
const { | ||
actions: { openRoom, openUserCard }, | ||
} = useMessageActions(); | ||
|
||
const isEncryptedMessage = isE2EEMessage(message); | ||
|
||
return ( | ||
<> | ||
{!isEncryptedMessage && !message.blocks && message.md && ( | ||
<MessageBodyRender | ||
onUserMentionClick={openUserCard} | ||
onChannelMentionClick={openRoom} | ||
mentions={message?.mentions || []} | ||
channels={message?.channels || []} | ||
tokens={message.md} | ||
disableBigEmoji={disableBigEmoji} | ||
/> | ||
)} | ||
|
||
{!isEncryptedMessage && !message.blocks && !message.md && message.msg} | ||
|
||
{isEncryptedMessage && <EncryptedMessageRender message={message} />} | ||
</> | ||
); | ||
}; | ||
|
||
export default memo(MessageRender); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters