mirror of
https://github.com/hmaxnl/SharpRSS.git
synced 2025-01-18 21:04:21 +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(),
|
Icon = reader["icon"].ToString(),
|
||||||
LastUpdated = DateTimeOffset.FromUnixTimeMilliseconds(long.Parse(reader["last_updated"].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);
|
categories.Add(categoryModel);
|
||||||
}
|
}
|
||||||
return categories;
|
return categories;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Argotic.Common;
|
using Argotic.Common;
|
||||||
using Argotic.Syndication;
|
using Argotic.Syndication;
|
||||||
|
@ -29,7 +30,19 @@ namespace SharpRss.Services
|
||||||
|
|
||||||
public async Task<CategoryModel?> CreateCategoryAsync(CategoryModel category) =>
|
public async Task<CategoryModel?> CreateCategoryAsync(CategoryModel category) =>
|
||||||
await DbAccess.SetCategoryAsync(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)
|
public async Task<bool> AddSubscriptionAsync(string url, CategoryModel? category = null)
|
||||||
{
|
{
|
||||||
var syndication = SyndicationManager.CreateSyndication(url);
|
var syndication = SyndicationManager.CreateSyndication(url);
|
||||||
|
|
|
@ -62,8 +62,8 @@
|
||||||
private async void ExpandedChanged(TreeItemData treeItemData)
|
private async void ExpandedChanged(TreeItemData treeItemData)
|
||||||
{
|
{
|
||||||
treeItemData.Loading = true;
|
treeItemData.Loading = true;
|
||||||
var groupedItems = await _syndicationService.GetFeedsAsync(treeItemData.CategoryModel?.Id);
|
if (treeItemData.CategoryModel != null)
|
||||||
treeItemData.Children = ModelToTreeItem(groupedItems);
|
treeItemData.Children = ModelToTreeItem(treeItemData.CategoryModel.Syndications);
|
||||||
treeItemData.IsExpanded = !treeItemData.IsExpanded;
|
treeItemData.IsExpanded = !treeItemData.IsExpanded;
|
||||||
treeItemData.Loading = false;
|
treeItemData.Loading = false;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user