Skip to content

Commit

Permalink
Merge pull request #11 from koalatiapp/fix-invalid-current-pagination
Browse files Browse the repository at this point in the history
fix: bad calculation of current item index in PaginatedList
  • Loading branch information
EmilePerron authored Mar 4, 2023
2 parents 88d6b54 + 4b6b018 commit 72767c3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Util/PaginatedList.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function fetchAll(): array
}

/**
* @return T
* @return ?T
*/
public function first(): mixed
{
Expand All @@ -89,7 +89,7 @@ public function first(): mixed

public function current(): mixed
{
$indexWithinPage = max(1, ($this->currentItemIndex % self::LIMIT)) - 1;
$indexWithinPage = $this->currentItemIndex % self::LIMIT;
$this->loadCurrentPage();

return $this->pages[$this->getCurrentPageIndex()][$indexWithinPage];
Expand Down

0 comments on commit 72767c3

Please sign in to comment.