SharpRSS/WebSharpRSS/Pages/Index.razor
2023-05-20 00:35:43 +02:00

68 lines
2.6 KiB
Plaintext

@page "/"
@using CodeHollow.FeedReader;
@using SharpRss.Models;
@using WebSharpRSS.Models;
@using SharpRss.Services
@inject FeedStateContainer _stateContainer;
<MudStack Spacing="2" Class="ml-2 mr-2">
@*@foreach (var feedItemData in _itemDatas)
{
<MudItem>
<MudCard>
<MudCardContent>
<div style="justify-self: start;" class="d-flex align-center">
@if (feedItemData.Icon != null)
{
<MudIcon Icon="@feedItemData.Icon" Style="@($"color:{feedItemData.CategoryColorHex}")" />
}
@if (feedItemData.FaviconUrl != null)
{
<MudImage Src="@feedItemData.FaviconUrl" ObjectFit="ObjectFit.Contain" />
}
<MudText Class="d-inline pa-2 align-center">@feedItemData.FeedItem.Title</MudText>
</div>
<MudText Typo="Typo.body2">@feedItemData.FeedItem.Description</MudText>
<MudText Typo="Typo.overline">@feedItemData.FeedItem.PublishingDate.ToString()</MudText>
</MudCardContent>
</MudCard>
</MudItem>
}*@
</MudStack>
@code {
protected override void OnInitialized()
{
UpdateFeeds();
//_stateContainer.StateChanged += FeedsChanged;
}
private void FeedsChanged()
{
UpdateFeeds();
InvokeAsync(StateHasChanged);
}
//private HashSet<FeedItemData> _itemDatas = new HashSet<FeedItemData>();
//private TreeItemData? _treeItemData;
private void UpdateFeeds()
{
/*if (_stateContainer.TreeItem == null) return;
_treeItemData = _stateContainer.TreeItem;
if (_treeItemData.Feed != null)
{
Feed feed = _treeItemData.Feed;
_itemDatas = feed.Items.Select(x => new FeedItemData(x) { Icon = _treeItemData.Icon, FaviconUrl = _treeItemData.FaviconUrl, CategoryColorHex = _treeItemData.CategoryModel?.HexColor }).ToHashSet();
}
else if (_treeItemData.Feeds != null)
{
HashSet<FeedItemData> items = new HashSet<FeedItemData>();
foreach (var treeItem in _treeItemData.Feeds)
{
if (treeItem.Feed == null) continue;
items.UnionWith(treeItem.Feed.Items.Select(x => new FeedItemData(x) { Icon = treeItem.Icon, FaviconUrl = treeItem.FaviconUrl, CategoryColorHex = _treeItemData.CategoryModel?.HexColor }));
_itemDatas = items.OrderBy(x => x.FeedItem.PublishingDate).Reverse().ToHashSet();
}
}*/
}
}