diff options
author | Eric Bailey <git@esb.lol> | 2023-11-14 11:28:40 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-14 11:28:40 -0600 |
commit | 3fde1bea1bffecb6740f261b88ceb34134e0d418 (patch) | |
tree | ff0b0a404376477a741033e02bffcfd553ff34d9 | |
parent | 4355f0fd9abf49e511027722dbec0816900da0ad (diff) | |
download | voidsky-3fde1bea1bffecb6740f261b88ceb34134e0d418.tar.zst |
Handle end of feed (#1898)
* Handle end of feed * Add isFetching
-rw-r--r-- | src/view/screens/Feeds.tsx | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/view/screens/Feeds.tsx b/src/view/screens/Feeds.tsx index 9c3d89005..7a3daee8d 100644 --- a/src/view/screens/Feeds.tsx +++ b/src/view/screens/Feeds.tsx @@ -107,6 +107,7 @@ export const FeedsScreen = withAuthRequired(function FeedsScreenImpl( refetch: refetchPopularFeeds, fetchNextPage: fetchNextPopularFeedsPage, isFetchingNextPage: isPopularFeedsFetchingNextPage, + hasNextPage: hasNextPopularFeedsPage, } = useGetPopularFeedsQuery() const {_} = useLingui() const setMinimalShellMode = useSetMinimalShellMode() @@ -154,6 +155,22 @@ export const FeedsScreen = withAuthRequired(function FeedsScreenImpl( await refetchPopularFeeds() setIsPTR(false) }, [setIsPTR, refetchPopularFeeds]) + const onEndReached = React.useCallback(() => { + if ( + isPopularFeedsFetching || + isUserSearching || + !hasNextPopularFeedsPage || + popularFeedsError + ) + return + fetchNextPopularFeedsPage() + }, [ + isPopularFeedsFetching, + isUserSearching, + popularFeedsError, + hasNextPopularFeedsPage, + fetchNextPopularFeedsPage, + ]) useFocusEffect( React.useCallback(() => { @@ -474,9 +491,7 @@ export const FeedsScreen = withAuthRequired(function FeedsScreenImpl( /> } initialNumToRender={10} - onEndReached={() => - isUserSearching ? undefined : fetchNextPopularFeedsPage() - } + onEndReached={onEndReached} // @ts-ignore our .web version only -prf desktopFixedHeight /> |