@page "/list" @using WebSharpRSS.Models @using SharpRss.Services @inject IDialogService _dialogService; @inject RssService _rssService;
@if (_isLoading) {
Loading...
} else { }
@code { [Parameter] [SupplyParameterFromQuery(Name = "fid")] public string? Fid { get => _fid; set { _fid = value; LoadItems(); } } private string? _fid; [Parameter] [SupplyParameterFromQuery(Name = "gid")] public string? Gid { get => _gid; set { _gid = value; LoadItems(); } } private string? _gid; HashSet items = new HashSet(); bool _isLoading = true; private async void LoadItems() { _isLoading = true; if (Fid != null) { var fItems = await _rssService.GetFeedItemsAsync(Fid); items = fItems.Select(x => FeedItemData.FromModel(x)).OrderBy(x => x.PublishingDate).Reverse().ToHashSet(); } else if (Gid != null) { var feeds = await _rssService.GetFeedsAsync(Gid); var feedIds = feeds.Select(x => x.OriginalUrl); var feedItems = await _rssService.GetFeedItemsFromFeedsAsync(feedIds.ToArray()); items = feedItems.Select(x => FeedItemData.FromModel(x)).OrderBy(x => x.PublishingDate).Reverse().ToHashSet(); } _isLoading = false; StateHasChanged(); } protected override void OnInitialized() { LoadItems(); } }