Skip to content

Commit 2468399

Browse files
author
Mishig
authored
[Assistnats] Fix pagination numTotalPages (#780)
* [Assistnats] Fix pagination numTotalPages * morereactivity
1 parent 3890de7 commit 2468399

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/lib/components/Pagination.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@
88
99
const ELLIPSIS_IDX = -1 as const;
1010
11-
const numTotalPages = Math.ceil(numTotalItems / numItemsPerPage);
11+
$: numTotalPages = Math.ceil(numTotalItems / numItemsPerPage);
1212
$: pageIndex = parseInt($page.url.searchParams.get("p") ?? "0");
13-
$: pageIndexes = getPageIndexes(pageIndex);
13+
$: pageIndexes = getPageIndexes(pageIndex, numTotalPages);
1414
1515
function getHref(pageIdx: number) {
1616
const newUrl = new URL($page.url);
1717
newUrl.searchParams.set("p", pageIdx.toString());
1818
return newUrl.toString();
1919
}
2020
21-
function getPageIndexes(pageIdx: number) {
21+
function getPageIndexes(pageIdx: number, nTotalPages: number) {
2222
let pageIdxs: number[] = [];
2323
2424
const NUM_EXTRA_BUTTONS = 2; // The number of page links to show on either side of the current page link.
2525
2626
const minIdx = 0;
27-
const maxIdx = numTotalPages - 1;
27+
const maxIdx = nTotalPages - 1;
2828
2929
pageIdxs = [pageIdx];
3030

0 commit comments

Comments
 (0)