diff --git a/native/chat/message-press-responder-context.js b/native/chat/message-press-responder-context.js new file mode 100644 --- /dev/null +++ b/native/chat/message-press-responder-context.js @@ -0,0 +1,13 @@ +// @flow + +import * as React from 'react'; + +export type MessagePressResponderContextType = { + +onPressMessage: () => void, +}; + +const MessagePressResponderContext: React.Context = React.createContext( + null, +); + +export { MessagePressResponderContext }; diff --git a/native/chat/text-message-tooltip-button.react.js b/native/chat/text-message-tooltip-button.react.js --- a/native/chat/text-message-tooltip-button.react.js +++ b/native/chat/text-message-tooltip-button.react.js @@ -10,6 +10,7 @@ import { InnerTextMessage } from './inner-text-message.react'; import { MessageHeader } from './message-header.react'; import { MessageListContextProvider } from './message-list-types'; +import { MessagePressResponderContext } from './message-press-responder-context'; import SidebarInputBarHeightMeasurer from './sidebar-input-bar-height-measurer.react'; import { useAnimatedMessageTooltipButton } from './utils'; @@ -67,6 +68,13 @@ const threadID = item.threadInfo.id; const { navigation, isOpeningSidebar } = props; + const messagePressResponderContext = React.useMemo( + () => ({ + onPressMessage: navigation.goBackOnce, + }), + [navigation.goBackOnce], + ); + const inlineSidebar = React.useMemo(() => { if (!item.threadCreatedFromMessage) { return null; @@ -92,12 +100,16 @@ - + + + {inlineSidebar} 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 @@ -25,6 +25,10 @@ import type { ChatNavigationProp } from './chat.react'; import ComposedMessage from './composed-message.react'; import { InnerTextMessage } from './inner-text-message.react'; +import { + MessagePressResponderContext, + type MessagePressResponderContextType, +} from './message-press-responder-context'; import textMessageSendFailed from './text-message-send-failed'; import { getMessageTooltipKey } from './utils'; @@ -50,6 +54,14 @@ }; class TextMessage extends React.PureComponent { message: ?React.ElementRef; + messagePressResponderContext: MessagePressResponderContextType; + + constructor(props: Props) { + super(props); + this.messagePressResponderContext = { + onPressMessage: this.onPress, + }; + } render() { const { @@ -81,19 +93,23 @@ } return ( - - - + sendFailed={textMessageSendFailed(item)} + focused={focused} + swipeOptions={swipeOptions} + {...viewProps} + > + + + ); }