mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2025-12-23 14:08:56 -05:00
use total_results for return condition
This commit is contained in:
@@ -51,10 +51,12 @@ const useInfiniteProjectsScroll = ( { params: newInputParams, enabled }: object
|
||||
/* eslint-disable consistent-return */
|
||||
{
|
||||
getNextPageParam: lastPage => {
|
||||
if ( !lastPage || lastPage.results.length < ITEMS_PER_PAGE ) {
|
||||
return undefined;
|
||||
}
|
||||
return lastPage.page + 1;
|
||||
if ( !lastPage ) return undefined;
|
||||
const totalProjectCount = lastPage.total_results;
|
||||
const totalFetchedCount = lastPage.page * ITEMS_PER_PAGE;
|
||||
return totalFetchedCount < totalProjectCount
|
||||
? lastPage.page + 1
|
||||
: undefined;
|
||||
},
|
||||
enabled
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user