Page MenuHomePhabricator

D9190.diff
No OneTemporary

D9190.diff

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
@@ -97,35 +97,6 @@
super(props);
}
- componentDidUpdate(prevProps: Props) {
- const { searchStatus } = this.props;
- const prevSearchStatus = prevProps.searchStatus;
-
- const isActiveOrActivating =
- searchStatus === 'active' || searchStatus === 'activating';
- const wasActiveOrActivating =
- prevSearchStatus === 'active' || prevSearchStatus === 'activating';
- if (isActiveOrActivating && !wasActiveOrActivating) {
- this.props.searchCancelButtonOpen.setValue(1);
- } else if (!isActiveOrActivating && wasActiveOrActivating) {
- this.props.searchCancelButtonOpen.setValue(0);
- }
-
- const { flatList } = this;
- if (!flatList) {
- return;
- }
-
- if (this.props.searchText !== prevProps.searchText) {
- flatList.scrollToOffset({ offset: 0, animated: false });
- return;
- }
-
- if (searchStatus === 'activating' && prevSearchStatus === 'inactive') {
- flatList.scrollToOffset({ offset: 0, animated: true });
- }
- }
-
render() {
return this.props.chatThreadList;
}
@@ -554,6 +525,29 @@
};
}, [hardwareBack]);
+ const isActiveOrActivating =
+ searchStatus === 'active' || searchStatus === 'activating';
+ React.useEffect(() => {
+ if (isActiveOrActivating) {
+ searchCancelButtonOpen.setValue(1);
+ } else {
+ searchCancelButtonOpen.setValue(0);
+ }
+ }, [isActiveOrActivating, searchCancelButtonOpen]);
+
+ React.useEffect(() => {
+ if (scrollPos.current > 0 && flatListRef.current) {
+ flatListRef.current.scrollToOffset({ offset: 0, animated: false });
+ }
+ }, [searchText]);
+
+ const isSearchActivating = searchStatus === 'activating';
+ React.useEffect(() => {
+ if (isSearchActivating && scrollPos.current > 0 && flatListRef.current) {
+ flatListRef.current.scrollToOffset({ offset: 0, animated: true });
+ }
+ }, [isSearchActivating]);
+
return (
<ChatThreadList
navigation={navigation}

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 5:23 PM (21 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2585580
Default Alt Text
D9190.diff (2 KB)

Event Timeline