2023-05-26 21:54:12 +02:00
|
|
|
@page "/list"
|
|
|
|
@using WebSharpRSS.Models
|
|
|
|
@using SharpRss.Services
|
|
|
|
|
|
|
|
@inject IDialogService _dialogService;
|
|
|
|
@inject RssService _rssService;
|
|
|
|
|
|
|
|
<div>
|
|
|
|
@if (_isLoading)
|
|
|
|
{
|
|
|
|
<div class="justify-self: center">
|
|
|
|
<MudProgressCircular Color="Color.Primary" Indeterminate="true" />
|
|
|
|
<MudText>Loading...</MudText>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<FeedItemList Items="items"/>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
@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<FeedItemData> items = new HashSet<FeedItemData>();
|
|
|
|
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);
|
2023-06-04 02:16:47 +02:00
|
|
|
var feedIds = feeds.Select(x => x.OriginalUrl);
|
2023-05-26 23:59:02 +02:00
|
|
|
var feedItems = await _rssService.GetFeedItemsFromFeedsAsync(feedIds.ToArray());
|
2023-05-26 21:54:12 +02:00
|
|
|
items = feedItems.Select(x => FeedItemData.FromModel(x)).OrderBy(x => x.PublishingDate).Reverse().ToHashSet();
|
|
|
|
}
|
|
|
|
_isLoading = false;
|
|
|
|
StateHasChanged();
|
|
|
|
}
|
|
|
|
protected override void OnInitialized()
|
|
|
|
{
|
|
|
|
LoadItems();
|
|
|
|
}
|
|
|
|
}
|