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

Connect: Highlight @ mentions to logged in user #10216

Merged
merged 5 commits into from Oct 8, 2020

Conversation

timorthi
Copy link
Contributor

@timorthi timorthi commented Sep 5, 2020

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

This PR distinguishes between mentions to the logged in user and mentions to other users by wrapping @-mentions to the logged in user with <mark>.

Based on my understanding, it's not possible to wrap <mark> tags at the time the message's HTML is generated in models/message.rb. Because of this, we'll have to highlight the @-mentions on the client side.

The implementation in this PR makes this feature quite obscure but it happens to be the implementation with the fewest lines of changed code, so I just rolled with it.

Related Tickets & Documents

#9472

QA Instructions, Screenshots, Recordings

  1. Join a group chat
  2. Mention someone else, observe that their link is not highlighted.
  3. Mention yourself, observe that your link is wrapped with <mark>

Screenshot from 2020-09-04 21-39-33

Added tests?

  • yes
  • no, because they aren't needed
  • no, because I need help

Added to documentation?

  • docs.forem.com
  • readme
  • no documentation needed

@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label Sep 5, 2020
@pr-triage pr-triage bot added PR: partially-approved bot applied label for PR's where a single reviewer approves changes and removed PR: unreviewed bot applied label for PR's with no review labels Sep 17, 2020
Copy link
Contributor

@nickytonline nickytonline 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! One change request.

app/javascript/chat/__tests__/message.test.jsx Outdated Show resolved Hide resolved
app/javascript/chat/__tests__/message.test.jsx Outdated Show resolved Hide resolved
@pr-triage pr-triage bot added PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes and removed PR: partially-approved bot applied label for PR's where a single reviewer approves changes labels Sep 17, 2020
@pr-triage pr-triage bot added PR: unreviewed bot applied label for PR's with no review and removed PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes labels Sep 18, 2020
@@ -38,4 +39,22 @@ describe('<Message />', () => {

expect(profileLink.parentElement).toHaveStyle({ color: msg.color });
});

it('should highlight @mentions to the logged in user', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick (non-blocking): Change the wording a bit.

Suggested change
it('should highlight @mentions to the logged in user', () => {
it('should highlight @mentions for the logged on user', () => {

Copy link
Contributor

Choose a reason for hiding this comment

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

logged on??? 🧐

Copy link
Contributor

@nickytonline nickytonline left a comment

Choose a reason for hiding this comment

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

Thanks so much for the PR @timorthi! 🚀

@pr-triage pr-triage bot added PR: partially-approved bot applied label for PR's where a single reviewer approves changes and removed PR: unreviewed bot applied label for PR's with no review labels Oct 8, 2020
@nickytonline nickytonline merged commit a943f04 into forem:master Oct 8, 2020
@pr-triage pr-triage bot added PR: merged bot applied label for PR's that are merged and removed PR: partially-approved bot applied label for PR's where a single reviewer approves changes labels Oct 8, 2020
boardfish pushed a commit to boardfish/forem that referenced this pull request Oct 17, 2020
* Wrap with <mark> tags if mentioning current user

* Add test for @mention highlight

* Match @{username} mention

* Remove default param
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: merged bot applied label for PR's that are merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants