2024-03-16 17:46:06 +08:00
|
|
|
|
namespace TaikoWebUI.Pages;
|
2022-09-12 00:33:58 +08:00
|
|
|
|
|
2023-11-11 21:04:11 +00:00
|
|
|
|
public partial class Users
|
2022-09-12 00:33:58 +08:00
|
|
|
|
{
|
2024-05-26 21:25:24 +01:00
|
|
|
|
// Tuple of User and UserSetting
|
|
|
|
|
private List<(User, UserSetting)>? usersWithSettings;
|
2022-09-12 00:33:58 +08:00
|
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
|
|
|
|
await base.OnInitializedAsync();
|
2024-05-25 18:12:30 +01:00
|
|
|
|
if (AuthService.LoginRequired && !AuthService.IsLoggedIn)
|
|
|
|
|
{
|
|
|
|
|
await AuthService.LoginWithAuthToken();
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-16 23:32:46 +01:00
|
|
|
|
if (AuthService.IsAdmin || !AuthService.LoginRequired)
|
|
|
|
|
{
|
2024-05-26 21:25:24 +01: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-16 23:32:46 +01:00
|
|
|
|
}
|
2022-09-12 00:33:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|