From 42966fb49ee3025029b0fd6726198a1ac2fc3899 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 29 Apr 2024 23:38:03 +0100 Subject: Fix List onMomentumScrollEnd (#3759) --- src/view/com/post-thread/PostThread.tsx | 72 ++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 33 deletions(-) (limited to 'src/view/com/post-thread/PostThread.tsx') diff --git a/src/view/com/post-thread/PostThread.tsx b/src/view/com/post-thread/PostThread.tsx index f4bf3b1ac..6e356f994 100644 --- a/src/view/com/post-thread/PostThread.tsx +++ b/src/view/com/post-thread/PostThread.tsx @@ -1,10 +1,12 @@ import React, {useEffect, useRef} from 'react' import {StyleSheet, useWindowDimensions, View} from 'react-native' +import {runOnJS} from 'react-native-reanimated' import {AppBskyFeedDefs} from '@atproto/api' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped' +import {ScrollProvider} from '#/lib/ScrollContext' import {isAndroid, isNative, isWeb} from '#/platform/detection' import { sortThread, @@ -276,8 +278,11 @@ export function PostThread({ setMaxParents(n => n + PARENTS_CHUNK_SIZE) } }, []) - const onMomentumScrollEnd = bumpMaxParentsIfNeeded const onScrollToTop = bumpMaxParentsIfNeeded + const onMomentumEnd = React.useCallback(() => { + 'worklet' + runOnJS(bumpMaxParentsIfNeeded)() + }, [bumpMaxParentsIfNeeded]) const onEndReached = React.useCallback(() => { if (isFetching || posts.length < maxReplies) return @@ -382,38 +387,39 @@ export function PostThread({ } return ( - - } - initialNumToRender={initialNumToRender} - windowSize={11} - /> + + + } + initialNumToRender={initialNumToRender} + windowSize={11} + /> + ) } -- cgit 1.4.1