Fixed multiple API calls made on the homepage page (#9406)

This commit is contained in:
Aniket Katkar 2022-12-19 20:31:09 +05:30 committed by GitHub
parent 497eca70ab
commit 0153cdfd69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,24 +175,23 @@ const MyData: React.FC<MyDataProps> = ({
); );
}, [ownedData, followedData, pendingTaskCount]); }, [ownedData, followedData, pendingTaskCount]);
const fetchMoreFeed = ( const fetchMoreFeed = useCallback(
isElementInView: boolean, (isElementInView: boolean, pagingObj: Paging) => {
pagingObj: Paging,
isLoading: boolean
) => {
if ( if (
isElementInView && isElementInView &&
pagingObj?.after && pagingObj?.after &&
!isLoading && !isFeedLoading &&
isMounted.current isMounted.current
) { ) {
fetchFeedHandler(feedFilter, pagingObj.after, threadType); fetchFeedHandler(feedFilter, pagingObj.after, threadType);
} }
}; },
[isFeedLoading, threadType, fetchFeedHandler, isMounted.current]
);
useEffect(() => { useEffect(() => {
fetchMoreFeed(Boolean(isInView), paging, isFeedLoading); fetchMoreFeed(Boolean(isInView), paging);
}, [isInView, paging, isFeedLoading]); }, [isInView, paging]);
useEffect(() => { useEffect(() => {
isMounted.current = true; isMounted.current = true;