mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2025-12-23 22:18:36 -05:00
stop making requests for projects if lastPage did not reach per_page limit
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user