-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pagination to Shopify integration #391
base: trunk
Are you sure you want to change the base?
Changes from all commits
d91e9bd
1ec7391
7a5ef2b
b8b23b2
18fea4a
52c0246
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import { | |
} from '@/blocks/remote-data-container/config/constants'; | ||
|
||
interface UsePaginationVariables { | ||
hasNextPage?: boolean; | ||
onFetch: ( remoteData: RemoteData ) => void; | ||
page: number; | ||
paginationQueryInput: RemoteDataQueryInput; | ||
|
@@ -88,6 +89,7 @@ export function usePaginationVariables( { | |
supportsCursorPagination || supportsPagePagination || supportsOffsetPagination; | ||
const totalItems = paginationData?.totalItems; | ||
const totalPages = totalItems && perPage ? Math.ceil( totalItems / perPage ) : undefined; | ||
const hasNextPage = paginationData?.hasNextPage; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you update the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something like this? const supportsPagination =
supportsCursorPagination ||
supportsPagePagination ||
supportsOffsetPagination ||
totalItems ||
hasNextPage; |
||
|
||
function onFetch( remoteData: RemoteData ): void { | ||
if ( ! supportsPagination ) { | ||
|
@@ -120,6 +122,7 @@ export function usePaginationVariables( { | |
} | ||
|
||
return { | ||
hasNextPage, | ||
onFetch, | ||
page, | ||
paginationQueryInput, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't quite work. The part in parentheses will always return a non-null value, so the
1
is never reachedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. What do you think of using
Math.max
?