SharpRSS/WebSharpRSS/Pages/Index.razor

68 lines
2.6 KiB
Plaintext
Raw Normal View History

2023-04-27 17:23:01 +02:00
@page "/"
2023-05-17 16:03:04 +02:00
@using CodeHollow.FeedReader;
@using SharpRss.Models;
@using WebSharpRSS.Models;
2023-05-18 01:27:11 +02:00
@using SharpRss.Services
2023-04-27 17:23:01 +02:00
2023-05-17 16:03:04 +02:00
@inject FeedStateContainer _stateContainer;
<MudStack Spacing="2" Class="ml-2 mr-2">
2023-05-20 00:04:45 +02:00
@*@foreach (var feedItemData in _itemDatas)
2023-05-17 16:03:04 +02:00
{
<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>
2023-05-20 00:04:45 +02:00
}*@
</MudStack>
2023-04-27 17:23:01 +02:00
@code {
protected override void OnInitialized()
2023-05-17 16:03:04 +02:00
{
UpdateFeeds();
2023-05-20 00:35:43 +02:00
//_stateContainer.StateChanged += FeedsChanged;
2023-05-17 16:03:04 +02:00
}
private void FeedsChanged()
{
UpdateFeeds();
InvokeAsync(StateHasChanged);
}
2023-05-20 00:04:45 +02:00
//private HashSet<FeedItemData> _itemDatas = new HashSet<FeedItemData>();
//private TreeItemData? _treeItemData;
2023-05-17 16:03:04 +02:00
private void UpdateFeeds()
{
2023-05-20 00:04:45 +02:00
/*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)
2023-05-17 16:03:04 +02:00
{
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();
}
2023-05-20 00:04:45 +02:00
}*/
2023-05-17 16:03:04 +02:00
}
2023-04-27 17:23:01 +02:00
}