Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3348303
D9136.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D9136.diff
View Options
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<GlobalAccountUserInfo>>,
+onChangeSearchText: (searchText: string) => Promise<void>,
+ +scrollPos: { current: number },
};
class ChatThreadList extends React.PureComponent<Props> {
searchInput: ?React.ElementRef<typeof TextInput>;
flatList: ?FlatList<Item>;
- 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 (
<ChatThreadList
navigation={navigation}
@@ -628,6 +630,7 @@
searchCancelButtonOffset={searchCancelButtonOffset}
searchUsers={searchUsers}
onChangeSearchText={onChangeSearchText}
+ scrollPos={scrollPos}
/>
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 2:24 PM (19 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2571143
Default Alt Text
D9136.diff (2 KB)
Attached To
Mode
D9136: [native] Replace `scrollPos` instance variable w/ ref
Attached
Detach File
Event Timeline
Log In to Comment