HomePhabricator
Diffusion Comm 5a960aae8d94

[native] Update the existing Context API for Markdown to encompass AppNavigator

Description

[native] Update the existing Context API for Markdown to encompass AppNavigator

Summary:
This diff handles refactoring the existing MarkdownContext API to encompass AppNavigator - this means that when each text-message now uses the MarkdownContext, that context is not unique-per-message. To solve this, the methods in the API take in messageID parameters, that maps a message to a boolean state in the Provider. The following was done in this diff in order to replicate existing behavior:

  1. Update the existing Context in markdown-context.js to use React.useState so we can update the state of a message and re-render automatically. This is of type Object, where the keys are messageIDs and the values are booleans.
  2. Introduce a clearMessageData method to clear data on unmount
  3. Create a markdown-context-provider.react.js. This allows the Context to track what message is being pressed and if it should be blocked from the tooltip appearing.
  4. Use this Context in ConnectedTextMessage to adjust linkIsBlockingPresses
  5. Pass in the messageID to MarkdownLink through a MessageContext so onPress, we can call setLinkModalActive or setLinkPressActive with the specific messageID being tapped
  6. Encompass App.Navigator within MarkdownContextProvider

This is Step 3 of https://linear.app/comm/issue/ENG-2072/maintain-the-spoiler-state-upon-opening-textmessagetooltipmodal

Depends on D5446

Test Plan:

  1. Checkout local master and test link taps and when the tooltip appears.
  2. Switch to this spoiler working state and simulate the same behavior to check that the tooltip does not appear when a link is touched.
  3. Behind the scenes, also log the Objects from the Provider useState hook in order to check that the boolean states are being updated for the correct Message.
  4. After that, check that the clearMessageData works as expected and data does not get persisted when a chat is swiped out of, and then re-entered.

Reviewers: atul, ginsu, ashoat

Reviewed By: atul, ashoat

Subscribers: abosh, tomek, ashoat

Differential Revision: https://phab.comm.dev/D5515

Details

Provenance
rohanAuthored on Nov 1 2022, 5:37 AM
Reviewer
atul
Differential Revision
D5515: [native] Update the existing Context API for Markdown to encompass AppNavigator
Parents
rCOMM63126dde46bb: [native] Rename MarkdownLinkContext to MarkdownContext
Branches
Unknown
Tags
Unknown