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 @@ -12,7 +12,7 @@ import { threadPermissions } from 'lib/types/thread-types'; import { ChatContext, type ChatContextType } from '../chat/chat-context'; -import { MarkdownLinkContext } from '../markdown/markdown-link-context'; +import { MarkdownContext } from '../markdown/markdown-context'; import { OverlayContext, type OverlayContextType, @@ -47,8 +47,9 @@ +canCreateSidebarFromMessage: boolean, // withOverlayContext +overlayContext: ?OverlayContextType, - // MarkdownLinkContext + // ChatContext +chatContext: ?ChatContextType, + // MarkdownContext +linkModalActive: boolean, }; class TextMessage extends React.PureComponent { @@ -223,7 +224,7 @@ const chatContext = React.useContext(ChatContext); const [linkModalActive, setLinkModalActive] = React.useState(false); - const markdownLinkContext = React.useMemo( + const markdownContext = React.useMemo( () => ({ setLinkModalActive, }), @@ -235,7 +236,7 @@ ); 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,13 @@ +// @flow + +import * as React from 'react'; + +export type MarkdownContextType = { + +setLinkModalActive: boolean => void, +}; + +const MarkdownContext: React.Context = React.createContext( + null, +); + +export { MarkdownContext }; 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]); @@ -51,7 +48,7 @@ }; function MarkdownLink(props: Props): React.Node { const { target, ...rest } = props; - const markdownLinkContext = React.useContext(MarkdownLinkContext); + const markdownLinkContext = React.useContext(MarkdownContext); const onPressLink = useDisplayLinkPrompt(target, markdownLinkContext); return ; }