2024-03-16 10:46:06 +01:00
|
|
|
|
namespace TaikoWebUI.Pages;
|
2022-09-11 18:33:58 +02:00
|
|
|
|
|
2023-11-11 22:04:11 +01:00
|
|
|
|
public partial class Users
|
2022-09-11 18:33:58 +02:00
|
|
|
|
{
|
2024-05-26 22:25:24 +02:00
|
|
|
|
// Tuple of User and UserSetting
|
|
|
|
|
private List<(User, UserSetting)>? usersWithSettings;
|
2022-09-11 18:33:58 +02:00
|
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
|
|
|
|
await base.OnInitializedAsync();
|
2024-05-25 19:12:30 +02:00
|
|
|
|
if (AuthService.LoginRequired && !AuthService.IsLoggedIn)
|
|
|
|
|
{
|
|
|
|
|
await AuthService.LoginWithAuthToken();
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-17 00:32:46 +02:00
|
|
|
|
if (AuthService.IsAdmin || !AuthService.LoginRequired)
|
|
|
|
|
{
|
2024-05-26 22:25:24 +02:00
|
|
|
|
var users = await Client.GetFromJsonAsync<List<User>>("api/Users");
|
|
|
|
|
var userSettings = await Client.GetFromJsonAsync<List<UserSetting>>("api/UserSettings");
|
|
|
|
|
if (users != null && userSettings != null)
|
|
|
|
|
{
|
|
|
|
|
// Combine User and UserSetting with the same Baid
|
|
|
|
|
usersWithSettings = users.Join(userSettings,
|
|
|
|
|
user => user.Baid,
|
|
|
|
|
setting => setting.Baid,
|
|
|
|
|
(user, setting) => (user, setting))
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
2024-05-17 00:32:46 +02:00
|
|
|
|
}
|
2022-09-11 18:33:58 +02:00
|
|
|
|
}
|
|
|
|
|
}
|