diff --git a/native/chat/text-message.react.js b/native/chat/text-message.react.js --- a/native/chat/text-message.react.js +++ b/native/chat/text-message.react.js @@ -50,7 +50,6 @@ // MarkdownLinkContext +chatContext: ?ChatContextType, +linkModalActive: boolean, - +linkIsBlockingPresses: boolean, }; class TextMessage extends React.PureComponent { message: ?React.ElementRef; @@ -74,7 +73,6 @@ overlayContext, chatContext, linkModalActive, - linkIsBlockingPresses, canCreateSidebarFromMessage, ...viewProps } = this.props; @@ -160,9 +158,9 @@ const { message, - props: { verticalBounds, linkIsBlockingPresses }, + props: { verticalBounds, linkModalActive }, } = this; - if (!message || !verticalBounds || linkIsBlockingPresses) { + if (!message || !verticalBounds || linkModalActive) { return; } @@ -225,20 +223,17 @@ const chatContext = React.useContext(ChatContext); const [linkModalActive, setLinkModalActive] = React.useState(false); - const [linkPressActive, setLinkPressActive] = React.useState(false); const markdownLinkContext = React.useMemo( () => ({ setLinkModalActive, - setLinkPressActive, }), - [setLinkModalActive, setLinkPressActive], + [setLinkModalActive], ); const canCreateSidebarFromMessage = useCanCreateSidebarFromMessage( props.item.threadInfo, props.item.messageInfo, ); - const linkIsBlockingPresses = linkModalActive || linkPressActive; return ( ); diff --git a/native/markdown/markdown-link-context.js b/native/markdown/markdown-link-context.js --- a/native/markdown/markdown-link-context.js +++ b/native/markdown/markdown-link-context.js @@ -4,7 +4,6 @@ export type MarkdownLinkContextType = { +setLinkModalActive: boolean => void, - +setLinkPressActive: boolean => void, }; const MarkdownLinkContext: React.Context = React.createContext( diff --git a/native/markdown/markdown-link.react.js b/native/markdown/markdown-link.react.js --- a/native/markdown/markdown-link.react.js +++ b/native/markdown/markdown-link.react.js @@ -1,7 +1,7 @@ // @flow import * as React from 'react'; -import { Text, Linking, Alert, Platform } from 'react-native'; +import { Text, Linking, Alert } from 'react-native'; import { normalizeURL } from 'lib/utils/url-utils'; @@ -50,42 +50,10 @@ ...TextProps, }; function MarkdownLink(props: Props): React.Node { - const markdownLinkContext = React.useContext(MarkdownLinkContext); - const { target, ...rest } = props; + const markdownLinkContext = React.useContext(MarkdownLinkContext); const onPressLink = useDisplayLinkPrompt(target, markdownLinkContext); - - const setLinkPressActive = markdownLinkContext?.setLinkPressActive; - const androidOnStartShouldSetResponderCapture = React.useCallback(() => { - setLinkPressActive?.(true); - return true; - }, [setLinkPressActive]); - - const activePressHasMoved = React.useRef(false); - const androidOnResponderMove = React.useCallback(() => { - activePressHasMoved.current = true; - }, []); - - const androidOnResponderTerminate = React.useCallback(() => { - if (!activePressHasMoved.current) { - onPressLink(); - } - activePressHasMoved.current = false; - setLinkPressActive?.(false); - }, [onPressLink, setLinkPressActive]); - - if (Platform.OS !== 'android') { - return ; - } - - // The Flow type for Text's props is missing onStartShouldSetResponderCapture - const gestureProps: any = { - onStartShouldSetResponderCapture: androidOnStartShouldSetResponderCapture, - onResponderMove: androidOnResponderMove, - onResponderTerminate: androidOnResponderTerminate, - }; - - return ; + return ; } export default MarkdownLink;