1
0
mirror of synced 2024-12-05 03:17:58 +01:00
TaikoLocalServer/TaikoWebUI/Pages/Users.razor.cs
shiibe 510a93c1aa Users api optimizations
* Moves the logic to attach user settings to the server
* Adds pagination to users request
2024-06-05 11:33:37 -04:00

41 lines
1.0 KiB
C#

namespace TaikoWebUI.Pages;
public partial class Users
{
private UsersResponse? response = new();
private int TotalPages { get; set; } = 0;
private bool isLoading = true;
private int currentPage = 1;
private int pageSize = 12;
private async Task GetUsersData()
{
isLoading = true;
response = await Client.GetFromJsonAsync<UsersResponse>($"api/Users?page={currentPage}&limit={pageSize}");
response.ThrowIfNull();
TotalPages = response.TotalPages;
isLoading = false;
}
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
if (AuthService.LoginRequired && !AuthService.IsLoggedIn)
{
await AuthService.LoginWithAuthToken();
}
if (AuthService.IsAdmin || !AuthService.LoginRequired)
{
await GetUsersData();
}
}
private async Task OnPageChange(int page)
{
currentPage = page;
await GetUsersData();
}
}