[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:
- 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.
- Introduce a clearMessageData method to clear data on unmount
- 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.
- Use this Context in ConnectedTextMessage to adjust linkIsBlockingPresses
- Pass in the messageID to MarkdownLink through a MessageContext so onPress, we can call setLinkModalActive or setLinkPressActive with the specific messageID being tapped
- 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:
- Checkout local master and test link taps and when the tooltip appears.
- Switch to this spoiler working state and simulate the same behavior to check that the tooltip does not appear when a link is touched.
- 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.
- 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