Skip to content

Restoring the grouped comments, and fixing the style for it#305

Merged
tgolen merged 4 commits into
masterfrom
afonseca_fix_grouping
Aug 27, 2020
Merged

Restoring the grouped comments, and fixing the style for it#305
tgolen merged 4 commits into
masterfrom
afonseca_fix_grouping

Conversation

@sketchydroide

@sketchydroide sketchydroide commented Aug 27, 2020

Copy link
Copy Markdown
Contributor

Fixes #44

Tests

  1. Create a series of messages from the same user, verify that they all group accordingly.
  2. Create a series of messages from another different user, verify that they all group accordingly, and none if the previous user group with the ones from this user.
  3. Verify that the chat on ReactNativeChat and Web-Expensify group the same way

Screenshots

Web ReactNative
Screenshot 2020-08-26 at 17 19 19 Screenshot 2020-08-26 at 17 19 30

@sketchydroide sketchydroide self-assigned this Aug 27, 2020
const previousAction = reportHistory[historyItemIndex - 1];
const currentAction = reportHistory[historyItemIndex];

if (currentAction.timestamp - previousAction.timestamp > 300) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

why 300, this value seems a bit random, I think we should create a constant for this at some point that has a comment explaining what this means

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.

300 is what the code in web-e has. I usually don't recommend moving things to a constant unless it's a value that changes often, or it is accessed in multiple places, so I'd just leave it as it is for now. The comment you could add might be something like this:

Comments are only grouped if they happen within 5 minutes of each other

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Let me add the comment before you merge

@sketchydroide sketchydroide requested a review from tgolen August 27, 2020 11:35
tgolen
tgolen previously approved these changes Aug 27, 2020

@tgolen tgolen left a comment

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.

LGTM. That ESLint warning about the long line is fixed in another PR.

I won't merge yet in case you'd like to add the comment about 300

<View>
{!displayAsGroup && (<ReportHistoryItemSingle historyItem={historyItem} authToken={authToken} />)}
{displayAsGroup && <ReportHistoryItemGrouped historyItem={historyItem} authToken={authToken} />}
{displayAsGroup && (<ReportHistoryItemGrouped historyItem={historyItem} authToken={authToken} />)}

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.

Usually, parentheses are only needed when there is multi-line JSX. Was the linter throwing a warning about this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added the parentheses because the ReportHistoryItemSingle had it as well, should I remove on both lines?

const previousAction = reportHistory[historyItemIndex - 1];
const currentAction = reportHistory[historyItemIndex];

if (currentAction.timestamp - previousAction.timestamp > 300) {

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.

300 is what the code in web-e has. I usually don't recommend moving things to a constant unless it's a value that changes often, or it is accessed in multiple places, so I'd just leave it as it is for now. The comment you could add might be something like this:

Comments are only grouped if they happen within 5 minutes of each other

@tgolen tgolen merged commit 63a3957 into master Aug 27, 2020
@tgolen tgolen deleted the afonseca_fix_grouping branch August 27, 2020 15:47
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.

Add comment grouping by author

2 participants