Skip to content

Commit

Permalink
fix(Pager): fetch only 2 * proximity ahead and behind. (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi authored Apr 2, 2024
1 parent 6701ab6 commit 47e4024
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* test: add tests for zero proximity pager, empty pager, and test current count for all
pagers
* fix(`OffsetPage`): fix `OutOfBoundsException` on an empty first page.
* fix(`Pager`): fetch only 2 * proximity ahead and behind.

## 0.5.2

Expand Down
4 changes: 2 additions & 2 deletions packages/rekapager-core/src/Pager/Internal/ProximityPager.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function __construct(
if ($currentIsFirstPage) {
$previousPages = [];
} else {
$previousPages = $currentPage->getPreviousPages($this->proximity * 2 + 2);
$previousPages = $currentPage->getPreviousPages($this->proximity * 2);
}

if (\count($previousPages) >= $this->proximity + 2) {
Expand All @@ -116,7 +116,7 @@ public function __construct(

// check next pages

$nextPages = $currentPage->getNextPages($this->proximity * 2 + 2);
$nextPages = $currentPage->getNextPages($this->proximity * 2);

if (\count($nextPages) >= $this->proximity + 2) {
$currentIsLastPage = false;
Expand Down

0 comments on commit 47e4024

Please sign in to comment.