Skip to content

Commit 1917124

Browse files
committed
Fix some issues with pagination
Pages start at 0 but the Client assumed that they start at 1. This fixes that.
1 parent ac89039 commit 1917124

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Client/Components/Pages/Search.razor

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@
4242
break;
4343
default:
4444
{
45+
var pageDisplay = Page + 1;
4546
<p>Found @TotalReplays replays in @stopWatch.ElapsedMilliseconds ms</p>
46-
<p>Page @Page of @TotalPages</p>
47+
<p>Page @pageDisplay of @TotalPages</p>
4748
<div class="replay-list">
4849
@foreach (var replay in Replays)
4950
{
@@ -52,14 +53,14 @@
5253
</div>
5354
<br/>
5455
<div class="pagination">
55-
@if (Page > 1)
56+
@if (Page > 0)
5657
{
5758
<button class="btn btn-primary" onclick="pageDown()">Previous page</button>
5859
} else
5960
{
6061
<button class="btn btn-primary" disabled>Previous page</button>
6162
}
62-
@if (Page < TotalPages)
63+
@if (Page < TotalPages - 1)
6364
{
6465
<button class="btn btn-primary" onclick="pageUp()">Next page</button>
6566
} else
@@ -75,11 +76,11 @@
7576
const currentPage = @Page;
7677
const totalPages = @TotalPages;
7778
function pageUp() {
78-
if (currentPage == totalPages) return;
79+
if (currentPage == (totalPages - 1)) return;
7980
search(currentPage + 1);
8081
}
8182
function pageDown() {
82-
if (currentPage == 1) return;
83+
if (currentPage == 0) return;
8384
search(currentPage - 1);
8485
}
8586
</script>

Client/Components/SearchBar.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
4242
document.querySelector('.search-bar input').addEventListener('keydown', (e) => {
4343
if (e.key === 'Enter') {
44-
search(1);
44+
search(0);
4545
}
4646
});
4747

0 commit comments

Comments
 (0)