Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3352153
D13825.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
D13825.diff
View Options
diff --git a/native/chat/chat-thread-list-item.react.js b/native/chat/chat-thread-list-item.react.js
--- a/native/chat/chat-thread-list-item.react.js
+++ b/native/chat/chat-thread-list-item.react.js
@@ -42,23 +42,6 @@
const styles = useStyles(unboundStyles);
const colors = useColors();
- const lastMessage = React.useMemo(() => {
- const mostRecentMessageInfo = data.mostRecentMessageInfo;
- if (!mostRecentMessageInfo) {
- return (
- <Text style={styles.noMessages} numberOfLines={1}>
- No messages
- </Text>
- );
- }
- return (
- <MessagePreview
- messageInfo={mostRecentMessageInfo}
- threadInfo={data.threadInfo}
- />
- );
- }, [data.mostRecentMessageInfo, data.threadInfo, styles]);
-
const numOfSidebarsWithExtendedArrow =
data.sidebars.filter(sidebarItem => sidebarItem.type === 'sidebar').length -
1;
@@ -172,7 +155,10 @@
</SingleLine>
</View>
<View style={styles.row}>
- {lastMessage}
+ <MessagePreview
+ messageInfo={data.mostRecentMessageInfo}
+ threadInfo={data.threadInfo}
+ />
<Text style={lastActivityStyle}>{lastActivity}</Text>
</View>
</View>
@@ -183,13 +169,13 @@
iconName,
lastActivity,
lastActivityStyle,
- lastMessage,
resolvedThreadInfo.uiName,
styles.header,
styles.iconContainer,
styles.row,
styles.threadDetails,
threadNameStyle,
+ data.mostRecentMessageInfo,
],
);
@@ -287,12 +273,6 @@
color: 'listForegroundLabel',
fontWeight: 'bold',
},
- noMessages: {
- color: 'listForegroundTertiaryLabel',
- flex: 1,
- fontSize: 14,
- fontStyle: 'italic',
- },
row: {
flexDirection: 'row',
justifyContent: 'space-between',
diff --git a/native/chat/message-preview.react.js b/native/chat/message-preview.react.js
--- a/native/chat/message-preview.react.js
+++ b/native/chat/message-preview.react.js
@@ -14,7 +14,7 @@
import { useStyles } from '../themes/colors.js';
type Props = {
- +messageInfo: MessageInfo,
+ +messageInfo: ?MessageInfo,
+threadInfo: ThreadInfo,
};
function MessagePreview(props: Props): React.Node {
@@ -26,14 +26,17 @@
threadInfo,
getDefaultTextMessageRules(chatMentionCandidates).simpleMarkdownRules,
);
- invariant(
- messagePreviewResult,
- 'useMessagePreview should only return falsey if pass null or undefined',
- );
+ const styles = useStyles(unboundStyles);
+ if (!messagePreviewResult) {
+ return (
+ <Text style={styles.noMessages} numberOfLines={1}>
+ No messages
+ </Text>
+ );
+ }
const { message, username } = messagePreviewResult;
let messageStyle;
- const styles = useStyles(unboundStyles);
if (message.style === 'unread') {
messageStyle = styles.unread;
} else if (message.style === 'primary') {
@@ -88,6 +91,12 @@
unread: {
color: 'listForegroundLabel',
},
+ noMessages: {
+ color: 'listForegroundTertiaryLabel',
+ flex: 1,
+ fontSize: 14,
+ fontStyle: 'italic',
+ },
};
export default MessagePreview;
diff --git a/native/chat/subchannel-item.react.js b/native/chat/subchannel-item.react.js
--- a/native/chat/subchannel-item.react.js
+++ b/native/chat/subchannel-item.react.js
@@ -25,22 +25,6 @@
const styles = useStyles(unboundStyles);
const unreadStyle = threadInfo.currentUser.unread ? styles.unread : null;
- const lastMessage = React.useMemo(() => {
- if (!mostRecentMessageInfo) {
- return (
- <Text style={styles.noMessages} numberOfLines={1}>
- No messages
- </Text>
- );
- }
- return (
- <MessagePreview
- messageInfo={mostRecentMessageInfo}
- threadInfo={threadInfo}
- />
- );
- }, [mostRecentMessageInfo, threadInfo, styles]);
-
return (
<View style={styles.outerView}>
<View style={styles.itemRowContainer}>
@@ -53,7 +37,10 @@
<SingleLine style={[styles.name, unreadStyle]}>{uiName}</SingleLine>
</View>
<View style={styles.itemRowContainer}>
- {lastMessage}
+ <MessagePreview
+ messageInfo={mostRecentMessageInfo}
+ threadInfo={threadInfo}
+ />
<Text style={[styles.lastActivity, unreadStyle]}>{lastActivity}</Text>
</View>
</View>
@@ -98,12 +85,6 @@
alignItems: 'center',
height: 24,
},
- noMessages: {
- color: 'listForegroundTertiaryLabel',
- flex: 1,
- fontSize,
- fontStyle: 'italic',
- },
};
export default SubchannelItem;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 4:48 AM (20 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2573525
Default Alt Text
D13825.diff (4 KB)
Attached To
Mode
D13825: [native] Handle rendering "No messages" inside MessagePreview
Attached
Detach File
Event Timeline
Log In to Comment