paginator: fix page 1 shown twice in empty searches.

Fix a bug where page 1 was shown twice (once for the current page, and
once for the last page) in searches that returned 0 results.
This commit is contained in:
evazion
2021-02-18 18:55:27 -06:00
parent b63d8207a9
commit 4e6dff782d
2 changed files with 44 additions and 27 deletions

View File

@@ -16,7 +16,7 @@ class PaginatorComponent < ApplicationComponent
end
def pages
last_page = total_pages
last_page = total_pages.clamp(1..)
left = (current_page - window).clamp(2..)
right = (current_page + window).clamp(..last_page - 1)
@@ -25,7 +25,7 @@ class PaginatorComponent < ApplicationComponent
("..." unless left == 2),
(left..right).to_a,
("..." unless right == last_page - 1),
last_page
(last_page unless last_page == 1)
].flatten.compact
end