Skip to content
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

Keep chats with draft comments in the LHN #781

Merged
merged 12 commits into from
Dec 1, 2020
Merged

Conversation

Gonals
Copy link
Contributor

@Gonals Gonals commented Nov 10, 2020

@nickmurray47 @tgolen, can you review?

Fixed Issues

Fixes $ https://github.com/Expensify/Expensify/issues/145380

Tests

  1. Open a chat in Native Chat, make sure it is not pinned and write a comment. Don't send it.
  2. While you are in the chat, nothing should change in the LHN.
  3. Leave the chat by selecting a different one. The first chat should remain in the LHN and have a little icon by it:

Screen Shot 2020-11-20 at 10 29 40 AM

4. Go back to the chat and delete the comment. When you leave the chat, it should go away from the LHN.

Screenshots

Screen Shot 2020-11-27 at 10 59 48 AM

Screen Shot 2020-11-27 at 11 09 34 AM

@Gonals Gonals requested a review from a team as a code owner November 10, 2020 10:39
@botify botify requested review from MariaHCD and removed request for a team November 10, 2020 10:39
@Gonals Gonals removed the request for review from MariaHCD November 10, 2020 12:35
@Gonals Gonals self-assigned this Nov 11, 2020
@Gonals Gonals changed the title Keep chats with draft comments in the LHN [HOLD] Keep chats with draft comments in the LHN Nov 13, 2020
@Gonals Gonals changed the title [HOLD] Keep chats with draft comments in the LHN Keep chats with draft comments in the LHN Nov 20, 2020
@Gonals Gonals requested a review from a team November 20, 2020 09:53
@botify botify requested review from nickmurray47 and removed request for a team November 20, 2020 09:53
@Gonals Gonals requested a review from a team November 20, 2020 09:53
@botify botify removed the request for review from a team November 20, 2020 09:54
@Gonals Gonals requested a review from a team November 20, 2020 09:55
@botify botify removed the request for review from a team November 20, 2020 09:55
@Gonals Gonals requested a review from tgolen November 20, 2020 10:11
@@ -34,13 +34,24 @@ const propTypes = {
unreadActionCount: PropTypes.number,
})),

// List of draft comments. We don't know the shape, since the keys include the report numbers

This comment was marked as resolved.

This comment was marked as resolved.

// eslint-disable-next-line max-len
const reportsToDisplay = _.filter(sortedReports, report => (report.isPinned || (report.unreadActionCount > 0) || report.reportID === reportIDInUrl));
const reportsToDisplay = _.filter(sortedReports, report => (report.isPinned || (report.unreadActionCount > 0) || report.reportID === reportIDInUrl || (report.reportID !== reportIDInUrl && get(props.comments, `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${report.reportID}`, '').length > 0)));
Copy link
Contributor

Choose a reason for hiding this comment

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

This filter is becoming pretty long. Can you please remove the eslint-disable and then split this filter onto multiple lines so it's nice and readable?

@@ -97,6 +110,9 @@ const SidebarLinks = (props) => {
login: participantDetails ? participantDetails.login : '',
reportID: report.reportID,
isUnread: report.unreadActionCount > 0,

// eslint-disable-next-line max-len
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, remove this and shorten the line instead. It looks like get(props.comments could be DRYed up somehow since I see it used elsewhere.

Copy link
Contributor

@nickmurray47 nickmurray47 left a comment

Choose a reason for hiding this comment

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

Looks good and tests well! A few small changes to make it seems.

@Gonals
Copy link
Contributor Author

Gonals commented Nov 23, 2020

Comments addressed!

@shawnborton
Copy link
Contributor

Can we see how this looks with super long emails/group names?

@@ -65,11 +65,13 @@ const SidebarLinks = (props) => {
'desc',
'asc'
]);
const hasComment = reportID => get(props.comments, `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`, '').length > 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is still having a lint warning for the line length. I have a few suggestions:

  1. Make it into a multi-line function like this:
function hasComment(reportID) {
    const reportComments = get(props.comments, `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`, '');
    return reportComments.length > 1;
}
  1. Define it outside the component and pass both reportID and props.comments as arguments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Fixed

@Gonals
Copy link
Contributor Author

Gonals commented Nov 24, 2020

Can we see how this looks with super long emails/group names?

Screen Shot 2020-11-24 at 11 15 22 AM

@shawnborton
Copy link
Contributor

It looks like the pencil icon and the text are not vertically aligned/centered. Does it look that way to you too?

@@ -58,10 +64,16 @@ const SidebarLinks = (props) => {
'desc',
'asc'
]);
function hasComment(reportID) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing method docs

Copy link
Contributor

Choose a reason for hiding this comment

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

Still missing method docs :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where? They are there!

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh wow, there they are. If you go to the "Conversation" tab in the PR and look at this conversation, it still shows the old code without the docs and that's what I was looking at. SOrry!

@Gonals
Copy link
Contributor Author

Gonals commented Nov 25, 2020

It looks like the pencil icon and the text are not vertically aligned/centered. Does it look that way to you too?

Yep, you are right. Seems to be happening for group chats. The icon is in the right spot, but the text is not centered:
Screen Shot 2020-11-25 at 12 46 28 PM
While it is in non-group chats:
Screen Shot 2020-11-25 at 12 46 59 PM

I'll play with the styles tomorrow to see if I can get the group text vertically centered (if that's what we want)

@shawnborton
Copy link
Contributor

Yup, we want them to be vertically centered. Thanks!

@Gonals
Copy link
Contributor Author

Gonals commented Nov 27, 2020

Yup, we want them to be vertically centered. Thanks!

There we go! We were adding an empty second line of text, which is why no centering properties were working!
Screenshots:
Screen Shot 2020-11-27 at 10 59 48 AM
Screen Shot 2020-11-27 at 11 09 34 AM

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.

4 participants