@@ -3,15 +3,15 @@ import {
33 useSuspenseInfiniteQuery ,
44 useSuspenseQuery ,
55} from '@tanstack/react-query' ;
6+ import { CategoryBookmarkArticleResponse } from '../types/api' ;
67import {
78 getBookmarkArticles ,
89 getBookmarkArticlesCount ,
910 getCategoryBookmarkArticles ,
1011 getCategoryBookmarkArticlesCount ,
1112} from './axios' ;
12- import {
13- CategoryBookmarkArticleResponse ,
14- } from '../types/api' ;
13+
14+ const PAGE_SIZE = 20 ;
1515
1616export const useGetBookmarkArticles = ( readStatus : boolean | null ) => {
1717 return useSuspenseInfiniteQuery ( {
@@ -20,7 +20,7 @@ export const useGetBookmarkArticles = (readStatus: boolean | null) => {
2020 getBookmarkArticles ( readStatus , Number ( pageParam ) , 20 ) ,
2121 initialPageParam : 0 ,
2222 getNextPageParam : ( lastPage , allPages ) =>
23- lastPage . articles . length === 0 ? undefined : allPages . length ,
23+ lastPage . articles . length < PAGE_SIZE ? undefined : allPages . length ,
2424 } ) ;
2525} ;
2626
@@ -55,7 +55,8 @@ export const useGetCategoryBookmarkArticles = (
5555
5656 initialPageParam : 0 ,
5757 getNextPageParam : ( lastPage , allPages ) => {
58- if ( ! lastPage || lastPage . articles . length === 0 ) return undefined ;
58+ if ( ! lastPage ) return undefined ;
59+ return lastPage . articles . length < PAGE_SIZE ? undefined : allPages . length ;
5960 return allPages . length ;
6061 } ,
6162 } ) ;
0 commit comments