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 @@ -125,12 +125,12 @@ usernamePrefix: string, ) => Promise<$ReadOnlyArray>, +onChangeSearchText: (searchText: string) => Promise, + +scrollPos: { current: number }, }; class ChatThreadList extends React.PureComponent { searchInput: ?React.ElementRef; flatList: ?FlatList; - scrollPos = 0; clearNavigationBlurListener: ?() => mixed; constructor(props: Props) { @@ -219,7 +219,7 @@ if (!this.props.navigation.isFocused()) { return; } - if (this.scrollPos > 0 && this.flatList) { + if (this.props.scrollPos.current > 0 && this.flatList) { this.flatList.scrollToOffset({ offset: 0, animated: true }); } else if (this.props.route.name === BackgroundChatThreadListRouteName) { this.props.navigation.navigate({ name: HomeChatThreadListRouteName }); @@ -230,7 +230,7 @@ if (this.props.searchStatus !== 'inactive') { return; } - if (this.scrollPos === 0) { + if (this.props.scrollPos.current === 0) { this.props.setSearchStatus('active'); } else { this.props.setSearchStatus('activating'); @@ -437,9 +437,9 @@ }; onScroll = (event: ScrollEvent) => { - const oldScrollPos = this.scrollPos; - this.scrollPos = event.nativeEvent.contentOffset.y; - if (this.scrollPos !== 0 || oldScrollPos === 0) { + const oldScrollPos = this.props.scrollPos.current; + this.props.scrollPos.current = event.nativeEvent.contentOffset.y; + if (this.props.scrollPos.current !== 0 || oldScrollPos === 0) { return; } if (this.props.searchStatus === 'activating') { @@ -598,6 +598,8 @@ [searchUsers, threadSearchIndex], ); + const scrollPos = React.useRef(0); + return ( ); }