Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #658 : Pager not working properly #713

Merged
merged 1 commit into from Jun 7, 2021
Merged

Fix #658 : Pager not working properly #713

merged 1 commit into from Jun 7, 2021

Conversation

jabby
Copy link
Collaborator

@jabby jabby commented Jun 7, 2021

Since the removal of "X-Total-Pages" and "X-Total" headers, all paginations use the kaminari counter.
In this mode, kaminari counter is reset to -1 during the call of the last page. This part is correct.
Then when we call the current() method of the pager to get the current page. This method call the same page method than the next method. In this method the pager check if there is element before checking if we call for the current page. It throws NoSuchElementException erroneously.

To fix, I change the check sequence. First I check ifthe user call the current page. If so, we return the corresponding items. If not we check if there is such elements and call the API.

Since the removal of "X-Total-Pages" and "X-Total" headers, all paginations use the kaminari counter.
In this mode, kaminari counter is reset to -1 during the call of the last page. This part is correct.
Then when we call the `current()` method of the pager to get the current page. This method call the same `page` method than the `next` method. In this method the pager check if there is element before checking if we call for the current page. It throws NoSuchElementException erroneously.

To fix, I change the check sequence. First I check ifthe user call the current page. If so, we return the corresponding items. If not we check if there is such elements and call the API.
@sonarcloud
Copy link

sonarcloud bot commented Jun 7, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@jabby jabby merged commit 69c15a3 into master Jun 7, 2021
@jabby jabby deleted the issue-658 branch June 7, 2021 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants