Page MenuHomePhabricator

[native] Make chat mentions clickable
ClosedPublic

Authored by patryk on Aug 19 2023, 10:03 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Mar 30, 1:14 PM
Unknown Object (File)
Wed, Mar 26, 10:50 PM
Unknown Object (File)
Tue, Mar 25, 2:33 PM
Unknown Object (File)
Mon, Mar 17, 3:35 AM
Unknown Object (File)
Mon, Mar 17, 3:33 AM
Unknown Object (File)
Fri, Mar 14, 10:18 PM
Unknown Object (File)
Feb 25 2025, 2:59 PM
Unknown Object (File)
Feb 25 2025, 2:59 PM
Subscribers

Details

Summary

Solution for ENG-4561.

This diff introduces new hook which redirects to chat when mention is clicked and uses it in markdown-utils.js and finally in markdown-chat-mention.react.js

Depends on D8845.

Test Plan

Before testing, please apply the entire native stack.

  1. Test if mentions inside a spoiler are properly rendered and are clickable only when spoiler is opened:

  1. Test if mentions are clickable and if animation is changed when tooltip is opened:

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

patryk held this revision as a draft.
patryk edited the test plan for this revision. (Show Details)
patryk added reviewers: tomek, inka, rohan.
patryk edited the summary of this revision. (Show Details)
patryk edited the summary of this revision. (Show Details)
patryk edited the test plan for this revision. (Show Details)

Add changes to markdown-chat-mention.react.js

native/chat/message-list-types.js
103–110 ↗(On Diff #30110)

This code is a little bit similar to useAnimatedNavigateToSidebar and useAnimatedMessageTooltipButton. Before navigating to thread, currentTransitionSidebarSourceID and sidebarAnimationType is set in ChatContext only when TextMessageTooltip is visible. That's because of this issue.

Why it is being set only when tooltip is visible? It's because currentTransitionSidebarSourceID is not changed to default null value. If you remove if clause, you can reproduce that error this way:

  1. Click on chat mention and wait for redirection
  2. Go back to previous chat
  3. Open text message tooltip. Weird behaviour of text message appears.

I also thought about refactoring useAnimatedMessageTooltipButton a little bit. What we could do is move this code:

React.useEffect(() => {
  return () => setCurrentTransitionSidebarSourceID(null);
}, [setCurrentTransitionSidebarSourceID]);

into text-message.react.js. Why this bug occurs? Above useEffect runs when useAnimatedMessageTooltipButton is used =>TextMessageTooltip is mounted.

native/markdown/markdown-utils.js
106–115 ↗(On Diff #30110)

I don't understand what the point of this function is.

  1. The React.useCallback appears to simply be creating an alias to navigateToThreadWithFadeAnimation
  2. navigateToThreadWithFadeAnimation itself appears to be being aliased in the whole function

What does this do that useNavigateToThreadWithFadeAnimation doesn't?

native/markdown/markdown-utils.js
106–115 ↗(On Diff #30110)

While I was working on this task, I was playing with setLinkModalActive and realised that there is no need to use this (initially I was setting linkModalActive before and after navigateToThreadWithFadeAnimation). So I deleted setLinkModalActive lines and left this alias code... Will fix that!

Use useNavigateToThreadWithFadeAnimation hook directly in component

Extract shouldBePressable condition from useMarkdownOnPressUtils

rohan requested changes to this revision.Aug 22 2023, 7:54 AM

Feel free to let me know if I'm missing something here with my comments. Requesting changes so it goes back to your queue

native/chat/message-list-types.js
97–98 ↗(On Diff #30224)

Since you've already checked whether chatContext exists using the invariant above, you should be able to remove the optional chaining here.

Also it might be easier if you just destructure, but up to you

107–108 ↗(On Diff #30224)

If you remove the optional chaining above since you've used an invariant, you should just be able to do this

This revision now requires changes to proceed.Aug 22 2023, 7:54 AM

Use isRevealed in onLongPress

Just one thing inline

native/chat/message-list-types.js
104–105 ↗(On Diff #30227)

I think you should either do what you did before after line 96

const setSidebarSourceID = chatContext.setCurrentTransitionSidebarSourceID;
const setSidebarAnimationType = chatContext.setSidebarAnimationType;

or destructure it after line 96

const { setCurrentTransitionSidebarSourceID: setSidebarSourceID, setSidebarAnimationType } = chatContext;

(choose whatever name you want, either setCurrentTransitionSidebarSourceID or setSidebarSourceID is fine)

So you can use them directly here

This revision is now accepted and ready to land.Aug 22 2023, 8:10 AM

Did you test whether the animation still works when user opens tooltip and presses "thread", even if the message has a link?

Yes, the sidebarAnimationType is set to move_source_message in this case.

This revision was automatically updated to reflect the committed changes.