Skip to content

Commit

Permalink
Incorporate review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
scottdixon committed Nov 25, 2024
1 parent d1f0013 commit 6c41604
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions packages/hydrogen/src/pagination/Pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ type PaginationState<NodesType> = {
pagination?: {
[key: string]: {
nodes: Array<NodesType>;
pageInfo: {
endCursor: Maybe<string> | undefined;
startCursor: Maybe<string> | undefined;
hasPreviousPage: boolean;
hasNextPage: boolean;
};
pageInfo?: PageInfo | null;
};
};
};
Expand Down Expand Up @@ -225,21 +220,14 @@ function getParamsWithoutPagination(
// Get all namespaces from state
const activeNamespaces = Object.keys(state?.pagination || {});

// Handle non-namespaced params (empty string namespace)
if (activeNamespaces.includes('')) {
params.delete('cursor');
params.delete('direction');
}

activeNamespaces
.filter((namespace) => namespace !== '')
.forEach((namespace) => {
const cursorParam = `${namespace}_cursor`;
const directionParam = `${namespace}_direction`;

params.delete(cursorParam);
params.delete(directionParam);
});
activeNamespaces.forEach((namespace) => {
// Clean up cursor and direction params for both namespaced and non-namespaced pagination
const namespacePrefix = namespace === '' ? '' : `${namespace}_`;
const cursorParam = `${namespacePrefix}cursor`;
const directionParam = `${namespacePrefix}direction`;
params.delete(cursorParam);
params.delete(directionParam);
});

return params.toString();
}
Expand Down

0 comments on commit 6c41604

Please sign in to comment.