Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3347541
D7770.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D7770.diff
View Options
diff --git a/native/chat/message-result.react.js b/native/chat/message-result.react.js
--- a/native/chat/message-result.react.js
+++ b/native/chat/message-result.react.js
@@ -10,6 +10,7 @@
import type { ChatNavigationProp } from './chat.react';
import { MessageListContextProvider } from './message-list-types.js';
import { Message } from './message.react.js';
+import { modifyItemForResultScreen } from './utils.js';
import type { AppNavigationProp } from '../navigation/app-navigator.react';
import type { NavigationRoute } from '../navigation/route-names';
import { useStyles } from '../themes/colors.js';
@@ -33,12 +34,17 @@
const onToggleFocus = React.useCallback(() => {}, []);
+ const item = React.useMemo(
+ () => modifyItemForResultScreen(props.item),
+ [props.item],
+ );
+
return (
<ScrollView style={styles.container}>
<MessageListContextProvider threadInfo={props.threadInfo}>
<View style={styles.viewContainer}>
<Message
- item={props.item}
+ item={item}
focused={false}
navigation={props.navigation}
route={props.route}
diff --git a/native/chat/message-results-screen.react.js b/native/chat/message-results-screen.react.js
--- a/native/chat/message-results-screen.react.js
+++ b/native/chat/message-results-screen.react.js
@@ -116,48 +116,6 @@
threadInfo,
]);
- const modifiedItems = React.useMemo(
- () =>
- measuredMessages.map(item => {
- invariant(item.itemType !== 'loader', 'should not be loader');
- invariant(
- item.messageShapeType !== 'robotext',
- 'should not be robotext',
- );
-
- if (item.messageShapeType === 'multimedia') {
- return {
- ...item,
- startsConversation: false,
- startsCluster: true,
- endsCluster: true,
- messageInfo: {
- ...item.messageInfo,
- creator: {
- ...item.messageInfo.creator,
- isViewer: false,
- },
- },
- };
- }
-
- return {
- ...item,
- startsConversation: false,
- startsCluster: true,
- endsCluster: true,
- messageInfo: {
- ...item.messageInfo,
- creator: {
- ...item.messageInfo.creator,
- isViewer: false,
- },
- },
- };
- }),
- [measuredMessages],
- );
-
const onLayout = React.useCallback(() => {
scrollViewContainerRef.current?.measure(
(x, y, width, height, pageX, pageY) => {
@@ -177,17 +135,21 @@
const messageResultsToDisplay = React.useMemo(
() =>
- modifiedItems.map(item => (
- <MessageResult
- key={item.messageInfo.id}
- item={item}
- threadInfo={threadInfo}
- navigation={navigation}
- route={route}
- messageVerticalBounds={messageVerticalBounds}
- />
- )),
- [modifiedItems, threadInfo, navigation, route, messageVerticalBounds],
+ measuredMessages.map(item => {
+ invariant(item.itemType !== 'loader', 'should not be loader');
+
+ return (
+ <MessageResult
+ key={item.messageInfo.id}
+ item={item}
+ threadInfo={threadInfo}
+ navigation={navigation}
+ route={route}
+ messageVerticalBounds={messageVerticalBounds}
+ />
+ );
+ }),
+ [measuredMessages, threadInfo, navigation, route, messageVerticalBounds],
);
return (
diff --git a/native/chat/toggle-pin-modal.react.js b/native/chat/toggle-pin-modal.react.js
--- a/native/chat/toggle-pin-modal.react.js
+++ b/native/chat/toggle-pin-modal.react.js
@@ -65,45 +65,6 @@
};
}, [isPinned, styles.pinButton, styles.removePinButton]);
- const modifiedItem = React.useMemo(() => {
- // The if / else if / else conditional is for Flow
- if (item.messageShapeType === 'robotext') {
- return item;
- } else if (item.messageShapeType === 'multimedia') {
- return {
- ...item,
- threadCreatedFromMessage: undefined,
- reactions: {},
- startsConversation: false,
- startsCluster: true,
- endsCluster: true,
- messageInfo: {
- ...item.messageInfo,
- creator: {
- ...item.messageInfo.creator,
- isViewer: false,
- },
- },
- };
- } else {
- return {
- ...item,
- threadCreatedFromMessage: undefined,
- reactions: {},
- startsConversation: false,
- startsCluster: true,
- endsCluster: true,
- messageInfo: {
- ...item.messageInfo,
- creator: {
- ...item.messageInfo.creator,
- isViewer: false,
- },
- },
- };
- }
- }, [item]);
-
const createToggleMessagePinPromise = React.useCallback(async () => {
invariant(messageInfo.id, 'messageInfo.id should be defined');
const result = await callToggleMessagePin({
@@ -136,7 +97,7 @@
{modalInfo.confirmationText}
</Text>
<MessageResult
- item={modifiedItem}
+ item={item}
threadInfo={threadInfo}
navigation={navigation}
route={route}
diff --git a/native/chat/utils.js b/native/chat/utils.js
--- a/native/chat/utils.js
+++ b/native/chat/utils.js
@@ -412,6 +412,44 @@
return messageKey(item.messageInfo);
}
+function modifyItemForResultScreen(
+ item: ChatMessageInfoItemWithHeight,
+): ChatMessageInfoItemWithHeight {
+ if (item.messageShapeType === 'robotext') {
+ return item;
+ }
+
+ if (item.messageShapeType === 'multimedia') {
+ return {
+ ...item,
+ startsConversation: false,
+ startsCluster: true,
+ endsCluster: true,
+ messageInfo: {
+ ...item.messageInfo,
+ creator: {
+ ...item.messageInfo.creator,
+ isViewer: false,
+ },
+ },
+ };
+ }
+
+ return {
+ ...item,
+ startsConversation: false,
+ startsCluster: true,
+ endsCluster: true,
+ messageInfo: {
+ ...item.messageInfo,
+ creator: {
+ ...item.messageInfo.creator,
+ isViewer: false,
+ },
+ },
+ };
+}
+
export {
chatMessageItemKey,
chatMessageItemHeight,
@@ -421,4 +459,5 @@
isMessageTooltipKey,
useContentAndHeaderOpacity,
useDeliveryIconOpacity,
+ modifyItemForResultScreen,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 12:31 PM (19 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2570621
Default Alt Text
D7770.diff (6 KB)
Attached To
Mode
D7770: [native] Extract function for modyfing items to be displayed in MessageResult
Attached
Detach File
Event Timeline
Log In to Comment