Skip to content

[IMPROVE] Message rewrite code structure#24723

Merged
gabriellsh merged 3 commits intomessage-template-2from
improveStructure
Mar 7, 2022
Merged

[IMPROVE] Message rewrite code structure#24723
gabriellsh merged 3 commits intomessage-template-2from
improveStructure

Conversation

@gabriellsh
Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

Comment on lines +61 to +63
const isEncryptedMessage = isE2EEMessage(message);
const encryptedMessageIsPending = isEncryptedMessage && message.e2e === 'pending';
const messageIsReady = !isEncryptedMessage || !encryptedMessageIsPending;
Copy link
Copy Markdown
Contributor

@filipemarins filipemarins Mar 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Comment on lines +14 to +16
if (!message.reactions || !Object.keys(message.reactions).length) {
return null;
}
Copy link
Copy Markdown
Contributor

@filipemarins filipemarins Mar 7, 2022

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.

https://dev.to/ucvdesh/stop-returning-null-components-312k

<MessageBody>
{encryptedMessageIsPending && t('E2E_message_encrypted_placeholder')}

{messageIsReady && !message.blocks && message.md && (
Copy link
Copy Markdown
Contributor

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');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gabriellsh gabriellsh merged commit 27378db into message-template-2 Mar 7, 2022
@gabriellsh gabriellsh deleted the improveStructure branch March 7, 2022 17:55
gabriellsh added a commit that referenced this pull request Mar 7, 2022
…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
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants