1
0
mirror of synced 2024-12-19 01:46:09 +01:00
TaikoLocalServer/TaikoWebUI/Components/Song/SongLeaderboardCard.razor.cs

40 lines
1.2 KiB
C#
Raw Normal View History

2024-06-03 01:55:44 +02:00

namespace TaikoWebUI.Components.Song;
public partial class SongLeaderboardCard
{
2024-06-03 03:00:54 +02:00
private SongLeaderboardResponse? response = null;
2024-06-03 01:55:44 +02:00
[Parameter]
public int SongId { get; set; }
[Parameter]
public int Baid { get; set; }
[Parameter]
2024-06-03 03:00:54 +02:00
public Difficulty Difficulty { get; set; } = Difficulty.Hard;
private string SelectedDifficulty { get; set; } = "Hard";
2024-06-03 01:55:44 +02:00
2024-06-03 17:03:09 +02:00
private bool isLoading = true;
2024-06-03 01:55:44 +02:00
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
2024-06-03 17:03:09 +02:00
response = await Client.GetFromJsonAsync<SongLeaderboardResponse>($"api/SongLeaderboard/{(uint)Baid}/{(uint)SongId}/{(uint)Difficulty}");
2024-06-03 01:55:44 +02:00
response.ThrowIfNull();
2024-06-03 17:03:09 +02:00
isLoading = false;
2024-06-03 03:00:54 +02:00
}
private async Task OnDifficultyChange(string difficulty)
{
2024-06-03 17:03:09 +02:00
isLoading = true;
2024-06-03 03:00:54 +02:00
SelectedDifficulty = difficulty;
Difficulty = Enum.Parse<Difficulty>(SelectedDifficulty);
2024-06-03 17:03:09 +02:00
response = await Client.GetFromJsonAsync<SongLeaderboardResponse>($"api/SongLeaderboard/{(uint)Baid}/{(uint)SongId}/{(uint)Difficulty}");
2024-06-03 03:00:54 +02:00
response.ThrowIfNull();
2024-06-03 17:03:09 +02:00
isLoading = false;
2024-06-03 01:55:44 +02:00
}
}