Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3399147
D9102.id30851.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D9102.id30851.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
@@ -61,32 +61,45 @@
data.sidebars.filter(sidebarItem => sidebarItem.type === 'sidebar').length -
1;
- const sidebars = data.sidebars.map((sidebarItem, index) => {
- if (sidebarItem.type === 'sidebar') {
- const { type, ...sidebarInfo } = sidebarItem;
- return (
- <ChatThreadListSidebar
- sidebarInfo={sidebarInfo}
- onPressItem={onPressItem}
- onSwipeableWillOpen={onSwipeableWillOpen}
- currentlyOpenedSwipeableId={currentlyOpenedSwipeableId}
- key={sidebarItem.threadInfo.id}
- extendArrow={index < numOfSidebarsWithExtendedArrow}
- />
- );
- } else if (sidebarItem.type === 'seeMore') {
- return (
- <ChatThreadListSeeMoreSidebars
- threadInfo={data.threadInfo}
- unread={sidebarItem.unread}
- onPress={onPressSeeMoreSidebars}
- key="seeMore"
- />
- );
- } else {
- return <View style={styles.spacer} key="spacer" />;
- }
- });
+ const sidebars = React.useMemo(
+ () =>
+ data.sidebars.map((sidebarItem, index) => {
+ if (sidebarItem.type === 'sidebar') {
+ const { type, ...sidebarInfo } = sidebarItem;
+ return (
+ <ChatThreadListSidebar
+ sidebarInfo={sidebarInfo}
+ onPressItem={onPressItem}
+ onSwipeableWillOpen={onSwipeableWillOpen}
+ currentlyOpenedSwipeableId={currentlyOpenedSwipeableId}
+ key={sidebarItem.threadInfo.id}
+ extendArrow={index < numOfSidebarsWithExtendedArrow}
+ />
+ );
+ } else if (sidebarItem.type === 'seeMore') {
+ return (
+ <ChatThreadListSeeMoreSidebars
+ threadInfo={data.threadInfo}
+ unread={sidebarItem.unread}
+ onPress={onPressSeeMoreSidebars}
+ key="seeMore"
+ />
+ );
+ } else {
+ return <View style={styles.spacer} key="spacer" />;
+ }
+ }),
+ [
+ currentlyOpenedSwipeableId,
+ data.sidebars,
+ data.threadInfo,
+ numOfSidebarsWithExtendedArrow,
+ onPressItem,
+ onPressSeeMoreSidebars,
+ onSwipeableWillOpen,
+ styles.spacer,
+ ],
+ );
const onPress = React.useCallback(() => {
onPressItem(data.threadInfo, data.pendingPersonalThreadUserInfo);
diff --git a/native/chat/chat-thread-list-sidebar.react.js b/native/chat/chat-thread-list-sidebar.react.js
--- a/native/chat/chat-thread-list-sidebar.react.js
+++ b/native/chat/chat-thread-list-sidebar.react.js
@@ -66,6 +66,11 @@
],
);
+ const sidebarItem = React.useMemo(
+ () => <SidebarItem sidebarInfo={sidebarInfo} />,
+ [sidebarInfo],
+ );
+
const swipeableThread = React.useMemo(
() => (
<View style={styles.swipeableThreadContainer}>
@@ -76,14 +81,16 @@
currentlyOpenedSwipeableId={currentlyOpenedSwipeableId}
iconSize={16}
>
- <SidebarItem sidebarInfo={sidebarInfo} />
+ {sidebarItem}
</SwipeableThread>
</View>
),
[
currentlyOpenedSwipeableId,
onSwipeableWillOpen,
- sidebarInfo,
+ sidebarInfo.mostRecentNonLocalMessage,
+ sidebarInfo.threadInfo,
+ sidebarItem,
styles.swipeableThreadContainer,
],
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 3, 2:04 AM (20 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2609318
Default Alt Text
D9102.id30851.diff (3 KB)
Attached To
Mode
D9102: [native] Memoize construction of `sidebars` in `ChatThreadListItem`
Attached
Detach File
Event Timeline
Log In to Comment