From 47e4024fb327e7fee96c5d52351573612df29045 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo <1102197+priyadi@users.noreply.github.com> Date: Tue, 2 Apr 2024 06:35:15 +0000 Subject: [PATCH] fix(`Pager`): fetch only 2 * proximity ahead and behind. (#15) --- CHANGELOG.md | 1 + packages/rekapager-core/src/Pager/Internal/ProximityPager.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1234b93..951ca18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/packages/rekapager-core/src/Pager/Internal/ProximityPager.php b/packages/rekapager-core/src/Pager/Internal/ProximityPager.php index 3ab1f5c..8246287 100644 --- a/packages/rekapager-core/src/Pager/Internal/ProximityPager.php +++ b/packages/rekapager-core/src/Pager/Internal/ProximityPager.php @@ -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) { @@ -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;