stop making requests for projects if lastPage did not reach per_page limit

This commit is contained in:
Abbey Campbell
2025-12-15 14:20:08 -08:00
parent 2c6eb6622a
commit 788246b187

View File

@@ -45,12 +45,18 @@ const useInfiniteProjectsScroll = ( { params: newInputParams, enabled }: object
}
return searchProjects( params, optsWithAuth );
},
// TO DO: we need to properly type queryOptions in useAuthenticatedInfiniteQuery
/* eslint-disable consistent-return */
{
getNextPageParam: lastPage => ( lastPage
? lastPage.page + 1
: 1 ),
getNextPageParam: lastPage => {
if ( !lastPage || lastPage.results.length < 20 ) {
return undefined;
}
return lastPage.page + 1;
},
enabled
}
/* eslint-enable consistent-return */
);
const pages = data?.pages;