diff --git a/native/chat/message-header.react.js b/native/chat/message-header.react.js
--- a/native/chat/message-header.react.js
+++ b/native/chat/message-header.react.js
@@ -30,15 +30,22 @@
const shouldShowUsername = !isViewer && (modalDisplay || item.startsCluster);
const stringForUser = useStringForUser(shouldShowUsername ? creator : null);
- let authorName = null;
- if (stringForUser) {
+ const authorNameStyle = React.useMemo(() => {
const style = [styles.authorName];
if (modalDisplay) {
style.push(styles.modal);
}
- authorName = {stringForUser};
- }
+ return style;
+ }, [modalDisplay, styles.authorName, styles.modal]);
+
+ const authorName = React.useMemo(() => {
+ if (!stringForUser) {
+ return null;
+ }
+
+ return {stringForUser};
+ }, [authorNameStyle, stringForUser]);
// We only want to render the top-placed timestamp for a message if it's
// rendered in the message list, and not any separate screens (i.e.
@@ -50,13 +57,25 @@
const messageInMessageList =
route.name === MessageListRouteName || presentedFromMessageList;
- const timestamp =
- messageInMessageList && (modalDisplay || item.startsConversation) ? (
-
- ) : null;
+ const timestamp = React.useMemo(() => {
+ if (!messageInMessageList || (!modalDisplay && !item.startsConversation)) {
+ return null;
+ }
+
+ return ;
+ }, [
+ display,
+ item.startsConversation,
+ messageInMessageList,
+ modalDisplay,
+ time,
+ ]);
+
+ const containerStyle = React.useMemo(() => {
+ if (!focused || modalDisplay) {
+ return null;
+ }
- let style = null;
- if (focused && !modalDisplay) {
let topMargin = 0;
if (!item.startsCluster && !item.messageInfo.creator.isViewer) {
topMargin += authorNameHeight + clusterEndHeight;
@@ -64,11 +83,18 @@
if (!item.startsConversation) {
topMargin += timestampHeight;
}
- style = { marginTop: topMargin };
- }
+
+ return { marginTop: topMargin };
+ }, [
+ focused,
+ item.messageInfo.creator.isViewer,
+ item.startsCluster,
+ item.startsConversation,
+ modalDisplay,
+ ]);
return (
-
+
{timestamp}
{authorName}