Skip to content

Commit

Permalink
fix(explorer): adjust pagination end calculation to respect available…
Browse files Browse the repository at this point in the history
… items (#4762)
  • Loading branch information
panteleymonchuk authored Jan 14, 2025
1 parent ed37c4c commit d90c78f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions apps/explorer/src/components/owned-objects/OwnedObjects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,15 @@ const VIEW_MODES = [
function getItemsRangeFromCurrentPage(
currentPage: number,
itemsPerPage: number,
availableItems?: number,
): ItemsRangeFromCurrentPage {
const start = currentPage * itemsPerPage + 1;
const end = start + itemsPerPage - 1;
let end = start + itemsPerPage - 1;

if (availableItems && availableItems < itemsPerPage) {
end = start + availableItems - 1;
}

return { start, end };
}

Expand Down Expand Up @@ -143,11 +149,7 @@ export function OwnedObjects({ id }: OwnedObjectsProps): JSX.Element {
);

const { start, end } = useMemo(
() =>
getItemsRangeFromCurrentPage(
pagination.currentPage,
filteredData?.length || PAGE_SIZES_RANGE_10_50[0],
),
() => getItemsRangeFromCurrentPage(pagination.currentPage, limit, filteredData?.length),
[filteredData?.length, pagination.currentPage],
);

Expand Down

0 comments on commit d90c78f

Please sign in to comment.