Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3355327
D5763.id19024.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D5763.id19024.diff
View Options
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<?MessagePressResponderContextType> = React.createContext<?MessagePressResponderContextType>(
+ 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 @@
<Animated.View style={headerStyle}>
<MessageHeader item={item} focused={true} display="modal" />
</Animated.View>
- <InnerTextMessage
- item={item}
- onPress={navigation.goBackOnce}
- threadColorOverride={threadColorOverride}
- isThreadColorDarkOverride={isThreadColorDarkOverride}
- />
+ <MessagePressResponderContext.Provider
+ value={messagePressResponderContext}
+ >
+ <InnerTextMessage
+ item={item}
+ onPress={navigation.goBackOnce}
+ threadColorOverride={threadColorOverride}
+ isThreadColorDarkOverride={isThreadColorDarkOverride}
+ />
+ </MessagePressResponderContext.Provider>
{inlineSidebar}
</Animated.View>
</MessageListContextProvider>
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<Props> {
message: ?React.ElementRef<typeof View>;
+ messagePressResponderContext: MessagePressResponderContextType;
+
+ constructor(props: Props) {
+ super(props);
+ this.messagePressResponderContext = {
+ onPressMessage: this.onPress,
+ };
+ }
render() {
const {
@@ -81,19 +93,23 @@
}
return (
- <ComposedMessage
- item={item}
- sendFailed={textMessageSendFailed(item)}
- focused={focused}
- swipeOptions={swipeOptions}
- {...viewProps}
+ <MessagePressResponderContext.Provider
+ value={this.messagePressResponderContext}
>
- <InnerTextMessage
+ <ComposedMessage
item={item}
- onPress={this.onPress}
- messageRef={this.messageRef}
- />
- </ComposedMessage>
+ sendFailed={textMessageSendFailed(item)}
+ focused={focused}
+ swipeOptions={swipeOptions}
+ {...viewProps}
+ >
+ <InnerTextMessage
+ item={item}
+ onPress={this.onPress}
+ messageRef={this.messageRef}
+ />
+ </ComposedMessage>
+ </MessagePressResponderContext.Provider>
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 2:21 PM (19 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2575593
Default Alt Text
D5763.id19024.diff (4 KB)
Attached To
Mode
D5763: [native] Pass TextMessage.onPress down via context
Attached
Detach File
Event Timeline
Log In to Comment