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 17:27:18 +02:00
|
|
|
|
public Difficulty Difficulty { get; set; } = Difficulty.None;
|
2024-06-03 03:00:54 +02:00
|
|
|
|
|
2024-06-03 17:27:18 +02:00
|
|
|
|
private string SelectedDifficulty { get; set; } = "None";
|
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:27:18 +02:00
|
|
|
|
// get highScoresTab from LocalStorage
|
|
|
|
|
var songPageDifficulty = await LocalStorage.GetItemAsync<string>("songPageDifficulty");
|
|
|
|
|
|
|
|
|
|
if (songPageDifficulty != null)
|
|
|
|
|
{
|
|
|
|
|
SelectedDifficulty = songPageDifficulty;
|
|
|
|
|
Difficulty = Enum.Parse<Difficulty>(SelectedDifficulty);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// set default difficulty to Easy
|
|
|
|
|
SelectedDifficulty = Difficulty.Easy.ToString();
|
|
|
|
|
Difficulty = Difficulty.Easy;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-04 02:05:14 +02:00
|
|
|
|
response = await Client.GetFromJsonAsync<SongLeaderboardResponse>($"api/SongLeaderboard/{(uint)SongId}?baid={(uint)Baid}&difficulty={(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:27:18 +02:00
|
|
|
|
|
|
|
|
|
await LocalStorage.SetItemAsync("songPageDifficulty", SelectedDifficulty);
|
|
|
|
|
|
2024-06-04 02:05:14 +02:00
|
|
|
|
response = await Client.GetFromJsonAsync<SongLeaderboardResponse>($"api/SongLeaderboard/{(uint)SongId}?baid={(uint)Baid}&difficulty={(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
|
|
|
|
}
|
2024-06-05 01:53:41 +02:00
|
|
|
|
|
|
|
|
|
private string GetActiveRowClass(SongLeaderboard leaderboard, int index)
|
|
|
|
|
{
|
|
|
|
|
return leaderboard.Baid == Baid ? "is-current-user" : "";
|
|
|
|
|
}
|
2024-06-03 01:55:44 +02:00
|
|
|
|
}
|