SharpRSS/SharpRss/Models/FeedModel.cs

44 lines
1.3 KiB
C#
Raw Normal View History

2023-05-12 23:58:49 +02:00
using System.Dynamic;
using System.Linq;
using System.Threading.Tasks;
using CodeHollow.FeedReader;
using Serilog;
using ToolQit.Extensions;
2023-05-12 15:48:14 +02:00
namespace SharpRss.Models
{
2023-05-12 23:58:49 +02:00
public class FeedModel : IGuideItem
2023-05-12 15:48:14 +02:00
{
2023-05-12 23:58:49 +02:00
public FeedModel(string rssUrl)
{
_rssUrl = rssUrl;
Task.Run(async () => Base = await FeedCache.GetFeed(_rssUrl));
}
public Feed Base { get; private set; }
public bool IsSelected { get; set; }
public bool IsExpanded { get; set; }
public bool IsReady { get; private set; }
private readonly string _rssUrl;
/*public async void Load(bool reload = false)
{
if (Base != null && !reload || !IsReady) return;
if (_rssUrl.IsNullEmptyWhiteSpace())
{
Log.Error("RSS Url is empty!");
return;
}
IsReady = false;
string feedUrl;
var urls = await FeedReader.GetFeedUrlsFromUrlAsync(_rssUrl);
if (!urls.Any())
feedUrl = _rssUrl;
else
feedUrl = urls.First().Url;
Log.Verbose("Creating feed: {FeedUrl}", feedUrl);
Base = await FeedReader.ReadAsync(feedUrl);
IsReady = true;
}*/
2023-05-12 15:48:14 +02:00
}
}