Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3359443
D9210.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
D9210.diff
View Options
diff --git a/native/chat/chat-thread-list-search.react.js b/native/chat/chat-thread-list-search.react.js
--- a/native/chat/chat-thread-list-search.react.js
+++ b/native/chat/chat-thread-list-search.react.js
@@ -80,8 +80,38 @@
],
[searchCancelButtonProgress, styles.cancelSearchButtonText],
);
- return (
- <>
+
+ const innerSearchNode = React.useMemo(
+ () => (
+ <Search
+ searchText={searchText}
+ onChangeText={onChangeText}
+ containerStyle={styles.search}
+ onBlur={onBlur}
+ placeholder="Search chats"
+ ref={ref}
+ autoFocus={innerSearchAutoFocus}
+ active={innerSearchActive}
+ />
+ ),
+ [
+ innerSearchActive,
+ innerSearchAutoFocus,
+ onBlur,
+ onChangeText,
+ ref,
+ searchText,
+ styles.search,
+ ],
+ );
+
+ const searchContainer = React.useMemo(
+ () => <AnimatedView style={searchBoxStyle}>{innerSearchNode}</AnimatedView>,
+ [innerSearchNode, searchBoxStyle],
+ );
+
+ const cancelButton = React.useMemo(
+ () => (
<Button
onPress={onSearchCancel}
disabled={searchStatus !== 'active'}
@@ -91,35 +121,24 @@
<Animated.Text style={buttonStyle}>Cancel</Animated.Text>
{/* eslint-enable react-native/no-raw-text */}
</Button>
- <AnimatedView style={searchBoxStyle}>
- <Search
- searchText={searchText}
- onChangeText={onChangeText}
- containerStyle={styles.search}
- onBlur={onBlur}
- placeholder="Search chats"
- ref={ref}
- autoFocus={innerSearchAutoFocus}
- active={innerSearchActive}
- />
- </AnimatedView>
- </>
+ ),
+ [buttonStyle, onSearchCancel, searchStatus, styles.cancelSearchButton],
+ );
+
+ const chatThreadListSearch = React.useMemo(
+ () => (
+ <>
+ {cancelButton}
+ {searchContainer}
+ </>
+ ),
+ [cancelButton, searchContainer],
);
+
+ return chatThreadListSearch;
}
const unboundStyles = {
- icon: {
- fontSize: 28,
- },
- container: {
- flex: 1,
- },
- searchContainer: {
- backgroundColor: 'listBackground',
- display: 'flex',
- justifyContent: 'center',
- flexDirection: 'row',
- },
searchBox: {
flex: 1,
},
@@ -142,10 +161,6 @@
paddingHorizontal: 16,
paddingTop: 8,
},
- flatList: {
- flex: 1,
- backgroundColor: 'listBackground',
- },
};
const ChatThreadListSearch: React.AbstractComponent<
diff --git a/native/chat/chat-thread-list.react.js b/native/chat/chat-thread-list.react.js
--- a/native/chat/chat-thread-list.react.js
+++ b/native/chat/chat-thread-list.react.js
@@ -494,28 +494,6 @@
justifyContent: 'center',
flexDirection: 'row',
},
- searchBox: {
- flex: 1,
- },
- search: {
- marginBottom: 8,
- marginHorizontal: 18,
- marginTop: 16,
- },
- cancelSearchButton: {
- position: 'absolute',
- right: 0,
- top: 0,
- bottom: 0,
- display: 'flex',
- justifyContent: 'center',
- },
- cancelSearchButtonText: {
- color: 'link',
- fontSize: 16,
- paddingHorizontal: 16,
- paddingTop: 8,
- },
flatList: {
flex: 1,
backgroundColor: 'listBackground',
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 9:07 AM (20 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2579145
Default Alt Text
D9210.diff (3 KB)
Attached To
Mode
D9210: [native] Add some basic memoization to `ChatThreadListSearch`
Attached
Detach File
Event Timeline
Log In to Comment