Skip to content

Commit

Permalink
fix: pagination issue in getSellOrdersExtendedQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
r41ph committed Oct 16, 2024
1 parent e95cd78 commit 61e3578
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ export const getSellOrdersExtendedQuery = ({
queryKey: [SELL_ORDERS_EXTENTED_KEY],
queryFn: async () => {
if (!client) return undefined;

let _request = { ...request };
// Fetching all sell orders
// TODO this could potentially be improved with pagination for the storefront page
let sellOrders: SellOrderInfo[] = [];
let response: QuerySellOrdersResponse | undefined;
while (!response || response.pagination?.nextKey?.length) {
if (response?.pagination?.nextKey?.length) {
request.pagination = { key: response.pagination.nextKey };
_request.pagination = { key: response.pagination.nextKey };
}
response = await client.SellOrders(request);
response = await client.SellOrders(_request);
sellOrders.push(...response.sellOrders);
}

Expand Down

0 comments on commit 61e3578

Please sign in to comment.