Page MenuHomePhabricator

[web] [refactor] last message color style
AbandonedPublic

Authored by benschac on Mar 21 2022, 12:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, May 24, 3:09 AM
Unknown Object (File)
Wed, May 22, 2:04 AM
Unknown Object (File)
Wed, May 15, 9:26 AM
Unknown Object (File)
Tue, May 14, 3:09 PM
Unknown Object (File)
Apr 20 2024, 5:56 AM
Unknown Object (File)
Apr 20 2024, 5:55 AM
Unknown Object (File)
Apr 20 2024, 5:42 AM
Unknown Object (File)
Apr 5 2024, 3:43 PM

Details

Summary

move repeated styles into top of the function.

Image 2022-03-21 at 3.55.51 PM.jpg (762×938 px, 52 KB)

Note: unread time padding needs to be fixed. I will do it in another diff.

Test Plan

send a couple of messages to yourself to make sure that read/unread message preview still work as expected.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

benschac edited the test plan for this revision. (Show Details)
benschac added reviewers: jacek, tomek.
benschac edited the summary of this revision. (Show Details)
tomek requested changes to this revision.Mar 22 2022, 4:37 AM

I'm not sure if defining all the styles at the top is the best idea - they should be defined closer to where they are used (before if (messageInfo.type === messageTypes.TEXT) {).

But there's more important issue here: if we should simplify this code even further. In one path we render

<div className={lastMsgCls}>
        {usernameText}
        {messageTitle}
      </div>

which differs by only usernameText from the last return. This is a great opportunity for simplification, because let usernameText = null; can be moved outside the if which will result in return being called after the if. That will also affect where the styles should be defined.

This diff already refactors and fixes the code, so I'm going to request changes. We can refactor and fix in the same diff, but finding a way to split it will be really appreciated.

web/chat/message-preview.react.js
42–62
This revision now requires changes to proceed.Mar 22 2022, 4:37 AM

Closing this diff in favor of my refactor stack.