Fix pagination for banned users in the mod panel (#1043)
Some checks failed
Continuous Integration / Build & Test (push) Has been cancelled
Upload Translations to Crowdin / crowdin-sync (push) Has been cancelled
Build Docker Image / Build and Publish (push) Has been cancelled
Qodana / qodana (push) Has been cancelled

This commit is contained in:
Josh 2025-01-10 23:19:14 -06:00 committed by GitHub
parent 376e1464a2
commit a528c65445
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,21 +21,25 @@ public class BannedUsersPage : BaseLayout
public int UserCount;
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)
public async Task<IActionResult> OnGet([FromRoute] int pageNumber)
{
WebTokenEntity? token = this.Database.WebTokenFromRequest(this.Request);
if (token == null) return this.Redirect("/login");
this.Users = await this.Database.Users
.Where(u => u.PermissionLevel < 0)
this.UserCount = await this.Database.Users.CountAsync(u => u.PermissionLevel < 0);
this.PageNumber = pageNumber;
this.PageAmount = Math.Max(1, (int)Math.Ceiling((double)this.UserCount / ServerStatics.PageSize));
if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount)
return this.Redirect($"/moderation/bannedUsers/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}");
this.Users = await this.Database.Users.Where(u => u.PermissionLevel < 0)
.OrderByDescending(u => u.UserId)
.Skip(pageNumber * ServerStatics.PageSize)
.Take(ServerStatics.PageSize)
.ToListAsync();
this.UserCount = await this.Database.Users.CountAsync(u => u.PermissionLevel < 0);
this.PageAmount = Math.Max(1, (int)Math.Ceiling((double)this.UserCount / ServerStatics.PageSize));
return this.Page();
}
}