-
Notifications
You must be signed in to change notification settings - Fork 10.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IMPROVE] Message rewrite code structure #24723
Conversation
018de3f
to
bf6651f
Compare
const isEncryptedMessage = isE2EEMessage(message); | ||
const encryptedMessageIsPending = isEncryptedMessage && message.e2e === 'pending'; | ||
const messageIsReady = !isEncryptedMessage || !encryptedMessageIsPending; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const isEncryptedMessage = isE2EEMessage(message); | |
const encryptedMessageIsPending = isEncryptedMessage && message.e2e === 'pending'; | |
const messageIsReady = !isEncryptedMessage || !encryptedMessageIsPending; | |
const isEncryptedMessage = isE2EEMessage(message); | |
const isEncryptedMessagePending = isEncryptedMessage && message.e2e === 'pending'; | |
const isMessageReady = !isEncryptedMessage || !encryptedMessageIsPending; |
I believe when the variable is boolean it is good to put the prefix is
.
if (!message.reactions || !Object.keys(message.reactions).length) { | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This conditional should be on the parent component.
example:
Message.tsx
{Object.keys(message.reactions).length && <MessageReactionsList />}
This way the component will not be loaded.
<MessageBody> | ||
{encryptedMessageIsPending && t('E2E_message_encrypted_placeholder')} | ||
|
||
{messageIsReady && !message.blocks && message.md && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe some const
to this case? like shoudShowMessageRender
?
import { useSetting } from '../../../../contexts/SettingsContext'; | ||
|
||
const MessageReadReceipt = (): ReactElement | null => { | ||
const isReadReceiptEnabled = useSetting('Message_Read_Receipt_Enabled'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe on MessageListProvider? can we centralize the Settings there.
…t into editContext * 'message-template-2' of github.com:RocketChat/Rocket.Chat: (33 commits) [IMPROVE] Message rewrite code structure (#24723) Fix messages being imported without sender's username (#24674) Bump actions/setup-node from 2 to 3 (#24642) i18n: Language update from LingoHub 🤖 on 2022-02-28Z (#24644) [FIX] Duplicated 'name' log key (#24590) Bump actions/checkout from 2 to 3 (#24668) Chore(deps-dev): Bump @types/mock-require from 2.0.0 to 2.0.1 (#24574) Bump ts-node from 10.5.0 to 10.6.0 in /ee/server/services (#24667) Bump @types/ws from 8.2.3 to 8.5.2 in /ee/server/services (#24666) Bump url-parse from 1.5.7 to 1.5.10 (#24640) [FIX] Typo in wrap-up term (#24661) [IMPROVE] Updated links in readme (#24028) Bump version to 4.6.0-develop Bump version to 4.5.0 Bump version to 4.5.0-rc.6 Chore: Update Apps-Engine (#24651) Bump version to 4.5.0-rc.5 Refresh server connection when MI server settings change (#24649) Bump version to 4.5.0-rc.4 Bump version to 4.5.0-rc.3 ...
Proposed changes (including videos or screenshots)
Issue(s)
Steps to test or reproduce
Further comments