@page "/list" @using WebSharpRSS.Models @using SharpRss.Services @inject IDialogService _dialogService; @inject SyndicationService _syndicationService;
@if (_isLoading) {
Loading...
} else { }
@code { [Parameter] [SupplyParameterFromQuery(Name = "fid")] public string? Fid { get => _fid; set { _fid = value; LoadItems(); } } private string? _fid; [Parameter] [SupplyParameterFromQuery(Name = "cid")] public string? Cid { get => _cid; set { _cid = value; LoadItems(); } } private string? _cid; HashSet items = new HashSet(); bool _isLoading = true; private async void LoadItems() { _isLoading = true; if (Fid != null) { var fItems = await _syndicationService.GetSyndicationItemsAsync(Fid); items = fItems.Select(x => SyndicationItemData.FromModel(x)).OrderBy(x => x.PublishingDate).Reverse().ToHashSet(); } else if (Cid != null) { var feeds = await _syndicationService.GetFeedsAsync(Cid == string.Empty ? null : Cid); var feedIds = feeds.Select(x => x.EncodedUrl); var feedItems = await _syndicationService.GetSyndicationItemsFromSyndicationsAsync(feedIds.ToArray()); items = feedItems.Select(x => SyndicationItemData.FromModel(x)).OrderBy(x => x.PublishingDate).Reverse().ToHashSet(); } _isLoading = false; StateHasChanged(); } protected override void OnInitialized() { LoadItems(); } }