@using SharpRss.Models @using SharpRss.Services @using WebSharpRSS.Models @using Serilog @inject SyndicationService _service; @if (Category != null) {
@Category.Name
@if (_isLoading) {
Loading...
} else {
} } else { Could not load data! }
@code { [Parameter] public CategoryModel? Category { get; set; } bool _isLoading = true; HashSet items = new HashSet(); async Task LoadDataAsync() { if (Category == null) { Log.Warning("Category is null!"); return; } _isLoading = true; var syndicationIds = Category.Syndications.Select(x => x.EncodedUrl); var syndicationItems = await _service.GetSyndicationItemsFromSyndicationsAsync(syndicationIds.ToArray()); items = syndicationItems.Select(x => SyndicationItemData.FromModel(x)).OrderBy(x => x.PublishingDate).Reverse().ToHashSet(); _isLoading = false; } protected override void OnInitialized() { Task.Run(async () => await LoadDataAsync()).ContinueWith(async t => await InvokeAsync(StateHasChanged)); } }