Fix erratic behavior of pull to refresh on threads (#7911)

This commit is contained in:
Daniel Espino García 2024-04-22 09:55:20 +02:00 committed by GitHub
parent 4084b21165
commit ca7915e2e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -156,6 +156,9 @@ const PostList = ({
}, []);
const onRefresh = useCallback(async () => {
if (disablePullToRefresh) {
return;
}
setRefreshing(true);
if (location === Screens.CHANNEL && channelId) {
await fetchPosts(serverUrl, channelId);
@ -170,7 +173,7 @@ const PostList = ({
await fetchPostThread(serverUrl, rootId, options);
}
setRefreshing(false);
}, [channelId, location, posts, rootId]);
}, [channelId, location, posts, rootId, disablePullToRefresh]);
const onScroll = useCallback((event: NativeSyntheticEvent<NativeScrollEvent>) => {
const {y} = event.nativeEvent.contentOffset;
@ -357,7 +360,7 @@ const PostList = ({
testID={`${testID}.flat_list`}
inverted={true}
refreshing={refreshing}
onRefresh={disablePullToRefresh ? undefined : onRefresh}
onRefresh={onRefresh}
/>
{location !== Screens.PERMALINK &&
<ScrollToEndView