1
0
mirror of synced 2024-12-04 10:57:59 +01:00
TaikoLocalServer/TaikoWebUI/Pages/SongList.razor.cs

75 lines
2.4 KiB
C#
Raw Normal View History

namespace TaikoWebUI.Pages;
2022-09-11 18:28:12 +02:00
public partial class SongList
2022-09-11 18:28:12 +02:00
{
[Parameter]
public int Baid { get; set; }
2024-05-17 00:32:46 +02:00
2024-03-14 05:38:26 +01:00
private string Search { get; set; } = string.Empty;
private string GenreFilter { get; set; } = string.Empty;
private string? SongNameLanguage { get; set; }
2024-03-14 05:38:26 +01:00
2022-09-11 18:28:12 +02:00
private SongBestResponse? response;
private UserSetting? userSetting;
2022-09-11 18:28:12 +02:00
2024-03-09 17:59:21 +01:00
private readonly List<BreadcrumbItem> breadcrumbs = new();
private Dictionary<uint, MusicDetail> musicDetailDictionary = new();
2024-03-14 03:27:55 +01:00
2022-09-11 18:28:12 +02:00
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
if (AuthService.LoginRequired && !AuthService.IsLoggedIn)
{
await AuthService.LoginWithAuthToken();
}
2022-09-11 18:28:12 +02:00
response = await Client.GetFromJsonAsync<SongBestResponse>($"api/PlayData/{Baid}");
response.ThrowIfNull();
userSetting = await Client.GetFromJsonAsync<UserSetting>($"api/UserSettings/{Baid}");
musicDetailDictionary = await GameDataService.GetMusicDetailDictionary();
2024-03-14 03:27:55 +01:00
SongNameLanguage = await LocalStorage.GetItemAsync<string>("songNameLanguage");
2024-03-09 00:42:56 +01:00
2024-05-17 00:32:46 +02:00
if (AuthService.IsLoggedIn && !AuthService.IsAdmin)
2024-03-09 17:59:21 +01:00
{
breadcrumbs.Add(new BreadcrumbItem(Localizer["Dashboard"], href: "/"));
2024-03-09 17:59:21 +01:00
}
else
{
breadcrumbs.Add(new BreadcrumbItem(Localizer["Users"], href: "/Users"));
2024-03-09 17:59:21 +01:00
};
breadcrumbs.Add(new BreadcrumbItem($"{userSetting?.MyDonName}", href: null, disabled: true));
breadcrumbs.Add(new BreadcrumbItem(Localizer["Song List"], href: $"/Users/{Baid}/Songs", disabled: false));
2022-09-11 18:28:12 +02:00
}
2024-03-14 05:38:26 +01:00
private bool FilterSongs(MusicDetail musicDetail)
2022-09-23 04:53:35 +02:00
{
2024-03-14 05:38:26 +01:00
var stringsToCheck = new List<string>
{
musicDetail.SongName,
musicDetail.SongNameEN,
musicDetail.SongNameCN,
musicDetail.SongNameKO,
musicDetail.ArtistName,
musicDetail.ArtistNameEN,
musicDetail.ArtistNameCN,
musicDetail.ArtistNameKO
};
if (!string.IsNullOrEmpty(Search) && !stringsToCheck.Any(s => s.Contains(Search, StringComparison.OrdinalIgnoreCase)))
{
return false;
}
if (!string.IsNullOrEmpty(GenreFilter) && musicDetail.Genre != Enum.Parse<SongGenre>(GenreFilter))
{
return false;
}
return true;
2022-09-11 18:28:12 +02:00
}
}