Page MenuHomePhorge

D9385.1768937714.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D9385.1768937714.diff

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 = <SingleLine style={style}>{stringForUser}</SingleLine>;
- }
+ return style;
+ }, [modalDisplay, styles.authorName, styles.modal]);
+
+ const authorName = React.useMemo(() => {
+ if (!stringForUser) {
+ return null;
+ }
+
+ return <SingleLine style={authorNameStyle}>{stringForUser}</SingleLine>;
+ }, [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) ? (
- <Timestamp time={time} display={display} />
- ) : null;
+ const timestamp = React.useMemo(() => {
+ if (!messageInMessageList || (!modalDisplay && !item.startsConversation)) {
+ return null;
+ }
+
+ return <Timestamp time={time} display={display} />;
+ }, [
+ 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 (
- <View style={style}>
+ <View style={containerStyle}>
{timestamp}
{authorName}
</View>

File Metadata

Mime Type
text/plain
Expires
Tue, Jan 20, 7:35 PM (6 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5958363
Default Alt Text
D9385.1768937714.diff (2 KB)

Event Timeline