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

Correct some improper code patterns #8733

Merged
merged 2 commits into from
Apr 26, 2022
Merged

Conversation

tgolen
Copy link
Contributor

@tgolen tgolen commented Apr 21, 2022

Details

As I was going through the code debugging another issue, I ran into these bad patterns.

Tests and QA

Test the comment copy

  1. Create a comment that has some markdown formatting (bold, underline, etc.) in it
  2. Once the comment is created, use the mouse to select the text of the comment and press ctrl+c to copy it
  3. Go to slack and paste it into the compose field and verify the formatting is intact

Test the unread message marker

  1. Have a chat with plenty of history that extends above the page
  2. Scroll up so you are not looking at the latest messages
  3. Send a message from the other participant
  4. Verify that the unread message indicator appears at the top of the page
  5. Scroll down to the bottom of the chat
  6. Verify that the unread message indicator goes away

Screenshots

Web

Mobile Web

2022-04-21_08-43-09 (1)

Desktop

2022-04-21_08-47-15 (1)

iO

2022-04-21_10-27-08 (1)

Android

2022-04-21_08-54-12 (1)

@tgolen tgolen requested a review from marcaaron as a code owner April 21, 2022 16:28
@tgolen tgolen self-assigned this Apr 21, 2022
}, copyShortcutConfig.descriptionKey, copyShortcutConfig.modifiers, false);
this.unsubscribeCopyShortcut = KeyboardShortcut.subscribe(
copyShortcutConfig.shortcutKey,
this.copySelectionToClipboard,
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Do we need to bind this in the constructor since we are refactoring the arrow function?

Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't look like the function is referencing this, so it looks like we don't need to in this case.

Copy link
Contributor

@marcaaron marcaaron Apr 21, 2022

Choose a reason for hiding this comment

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

separate thought: Why do we need a keyboard event for copying text? 😵‍💫

Maybe we can add some context to the copySelectionToClipboard() JSDoc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, Rory is correct.

As for why it's needed, it came from this PR #6732 and it's so that markdown formatting is preserved when copying selected text.

Which indicates that I need to update the testing instructions 😁

this.setState({localUnreadActionCount: 0});
this.setState({
isMarkerActive: false,
localUnreadActionCount: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

@parasharrajat @roryabraham do either of you know whether this callback is doing anything?

introduced here: #4773

Copy link
Member

Choose a reason for hiding this comment

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

I think I moved the count reset to the callback so that the user does not see an immediate reset to 0 while the MarkerBadge is hiding. Not the best way to do this as animation has a timeout but this callback will fire early.

Copy link
Contributor

Choose a reason for hiding this comment

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

so that the user does not see an immediate reset to 0 while the MarkerBadge is hiding. Not the best way to do this as animation has a timeout but this callback will fire early.

thought: Perhaps a better way to do that is to wait until the animation is over to set the unread action count.

@tgolen not sure if we need to do anything here though as unclear if the original concern is something we should solve for i.e.

so that the user does not see an immediate reset to 0 while the MarkerBadge is hiding

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO since the animation is short, it doesn't really matter what the count is. I agree that if it does matter, listening to the end of the animation event sounds like a better solution.

@parasharrajat
Copy link
Member

parasharrajat commented Apr 21, 2022

@tgolen Here is the PR which adds localunreadCount #4773. Maybe it will be helpful in understanding its use.

@tgolen
Copy link
Contributor Author

tgolen commented Apr 25, 2022

Bump for reviews again. I don't think either of the comments above need to be addressed with changes.

@roryabraham roryabraham merged commit fbe338c into main Apr 26, 2022
@roryabraham roryabraham deleted the tgolen-fix-unreadcounter branch April 26, 2022 01:10
@OSBotify
Copy link
Contributor

OSBotify commented May 9, 2022

🚀 Cherry-picked to staging by @sketchydroide in version: 1.1.57-8 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes.

@chiragsalian
Copy link
Contributor

Btw, QA is unable to test part of this because of this issue.
For now i have checked it off the list since i don't think its valid to hold deploy on this because another related issue exists on production. So once this is resolved we can test the rest of this PR or if you have any other way to test this now, feel free to test and update us 🙂

@tgolen
Copy link
Contributor Author

tgolen commented May 13, 2022

OK, yeah, I think checking it off is fine.

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @chiragsalian in version: 1.1.57-17 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@MonilBhavsar
Copy link
Contributor

Coming from #8930
@chiragsalian I think if you check Format messages with markup in Slack, Preferences > Advanced then you should be able to QA this.

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.

7 participants