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 @@ -11,7 +11,7 @@ } from 'lib/shared/thread-utils'; import { threadPermissions } from 'lib/types/thread-types'; -import { MarkdownLinkContext } from '../markdown/markdown-link-context'; +import { MarkdownContext } from '../markdown/markdown-context'; import { OverlayContext, type OverlayContextType, @@ -42,7 +42,7 @@ +canCreateSidebarFromMessage: boolean, // withOverlayContext +overlayContext: ?OverlayContextType, - // MarkdownLinkContext + // MarkdownContext +linkModalActive: boolean, +linkIsBlockingPresses: boolean, }; @@ -202,7 +202,7 @@ const [linkModalActive, setLinkModalActive] = React.useState(false); const [linkPressActive, setLinkPressActive] = React.useState(false); - const markdownLinkContext = React.useMemo( + const markdownContext = React.useMemo( () => ({ setLinkModalActive, setLinkPressActive, @@ -216,7 +216,7 @@ const linkIsBlockingPresses = linkModalActive || linkPressActive; return ( - + - + ); }, ); diff --git a/native/markdown/markdown-context.js b/native/markdown/markdown-context.js new file mode 100644 --- /dev/null +++ b/native/markdown/markdown-context.js @@ -0,0 +1,14 @@ +// @flow + +import * as React from 'react'; + +export type MarkdownContextType = { + +setLinkModalActive: boolean => void, + +setLinkPressActive: boolean => void, +}; + +const MarkdownContext: React.Context = React.createContext( + null, +); + +export { MarkdownContext }; diff --git a/native/markdown/markdown-link-context.js b/native/markdown/markdown-link-context.js deleted file mode 100644 --- a/native/markdown/markdown-link-context.js +++ /dev/null @@ -1,14 +0,0 @@ -// @flow - -import * as React from 'react'; - -export type MarkdownLinkContextType = { - +setLinkModalActive: boolean => void, - +setLinkPressActive: boolean => void, -}; - -const MarkdownLinkContext: React.Context = React.createContext( - null, -); - -export { MarkdownLinkContext }; 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 @@ -5,16 +5,13 @@ import { normalizeURL } from 'lib/utils/url-utils'; -import { - MarkdownLinkContext, - type MarkdownLinkContextType, -} from './markdown-link-context'; +import { MarkdownContext, type MarkdownContextType } from './markdown-context'; function useDisplayLinkPrompt( inputURL: string, - markdownLinkContext: ?MarkdownLinkContextType, + markdownContext: ?MarkdownContextType, ) { - const setLinkModalActive = markdownLinkContext?.setLinkModalActive; + const setLinkModalActive = markdownContext?.setLinkModalActive; const onDismiss = React.useCallback(() => { setLinkModalActive?.(false); }, [setLinkModalActive]); @@ -50,12 +47,12 @@ ...TextProps, }; function MarkdownLink(props: Props): React.Node { - const markdownLinkContext = React.useContext(MarkdownLinkContext); + const markdownContext = React.useContext(MarkdownContext); const { target, ...rest } = props; - const onPressLink = useDisplayLinkPrompt(target, markdownLinkContext); + const onPressLink = useDisplayLinkPrompt(target, markdownContext); - const setLinkPressActive = markdownLinkContext?.setLinkPressActive; + const setLinkPressActive = markdownContext?.setLinkPressActive; const androidOnStartShouldSetResponderCapture = React.useCallback(() => { setLinkPressActive?.(true); return true;