SharpRSS/WebSharpRSS/Models/TreeItemData.cs
2023-06-01 15:55:15 +02:00

38 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using MudBlazor;
using SharpRss.Models;
using ToolQit;
namespace WebSharpRSS.Models
{
public class TreeItemData
{
public TreeItemData(CategoryModel groupModel)
{
GroupModel = groupModel;
Title = groupModel.Name;
Icon = groupModel.Icon == string.Empty ? Icons.Material.Filled.RssFeed : groupModel.Icon;
HasChild = groupModel.FeedCount > 0;
}
public TreeItemData(FeedModel feedModel)
{
FeedModel = feedModel;
Title = feedModel.Title ?? string.Empty;
if (FeedModel.Url == null) return;
FaviconUrl = string.Format(Caretaker.Settings["Paths"].GetString("FaviconResolveUrl"), new Uri(FeedModel.Url).Host);
}
public readonly CategoryModel? GroupModel;
public readonly FeedModel? FeedModel;
public HashSet<TreeItemData>? Children { get; set; }
public string Title { get; set; }
public bool IsSelected { get; set; }
public string? Icon { get; set; }
public string? FaviconUrl { get; set; }
public bool HasChild { get; set; }
public bool Loading { get; set; }
public bool IsExpanded { get; set; }
}
}