mirror of
https://github.com/hmaxnl/SharpRSS.git
synced 2025-01-18 12:54:20 +01:00
Reworked fetching of categories.
This commit is contained in:
parent
dfc9db7944
commit
3e570a40a2
|
@ -48,8 +48,6 @@ namespace SharpRss
|
|||
Icon = reader["icon"].ToString(),
|
||||
LastUpdated = DateTimeOffset.FromUnixTimeMilliseconds(long.Parse(reader["last_updated"].ToString()))
|
||||
};
|
||||
categoryModel.Syndications = await GetSyndicationsAsync(new []{ categoryModel.Id });
|
||||
//categoryModel.SyndicationCount = await dbc.ExecuteScalarAsync<int>($"SELECT COUNT(*) FROM syndication WHERE category_id=@CatId", new { CatId = categoryModel.Id });
|
||||
categories.Add(categoryModel);
|
||||
}
|
||||
return categories;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Argotic.Common;
|
||||
using Argotic.Syndication;
|
||||
|
@ -29,7 +30,19 @@ namespace SharpRss.Services
|
|||
|
||||
public async Task<CategoryModel?> CreateCategoryAsync(CategoryModel category) =>
|
||||
await DbAccess.SetCategoryAsync(category);
|
||||
public async Task<HashSet<CategoryModel>> GetCategoriesAsync() => await DbAccess.GetCategoriesAsync();
|
||||
|
||||
public async Task<HashSet<CategoryModel>> GetCategoriesAsync()
|
||||
{
|
||||
HashSet<CategoryModel> categories = await DbAccess.GetCategoriesAsync();
|
||||
foreach (CategoryModel catModel in categories)
|
||||
{
|
||||
catModel.Syndications = await DbAccess.GetSyndicationsAsync(new[] { catModel.Id });
|
||||
}
|
||||
return categories;
|
||||
}
|
||||
|
||||
private async void ForEachCategories(CategoryModel x) => x.Syndications = await DbAccess.GetSyndicationsAsync(new[] { x.Id });
|
||||
|
||||
public async Task<bool> AddSubscriptionAsync(string url, CategoryModel? category = null)
|
||||
{
|
||||
var syndication = SyndicationManager.CreateSyndication(url);
|
||||
|
|
|
@ -62,8 +62,8 @@
|
|||
private async void ExpandedChanged(TreeItemData treeItemData)
|
||||
{
|
||||
treeItemData.Loading = true;
|
||||
var groupedItems = await _syndicationService.GetFeedsAsync(treeItemData.CategoryModel?.Id);
|
||||
treeItemData.Children = ModelToTreeItem(groupedItems);
|
||||
if (treeItemData.CategoryModel != null)
|
||||
treeItemData.Children = ModelToTreeItem(treeItemData.CategoryModel.Syndications);
|
||||
treeItemData.IsExpanded = !treeItemData.IsExpanded;
|
||||
treeItemData.Loading = false;
|
||||
StateHasChanged();
|
||||
|
|
Loading…
Reference in New Issue
Block a user