Start adding Miniflux support plus other cleanup

- Modernize old async code
- Update to .NET 10
- Adjust namespace
- Bypass update check when debugging
This commit is contained in:
2025-11-13 10:33:56 -05:00
parent cdd22c6632
commit 6bae35a255
56 changed files with 560 additions and 326 deletions

View File

@@ -35,8 +35,8 @@ public partial class App
var app = new App(); var app = new App();
app.InitializeComponent(); app.InitializeComponent();
// Create an single instance handle to see if we are already running // Create a single instance handle to see if we are already running
var isolationHandle = SingleInstance.GetSingleInstanceHandleAsync(Name).Result; var isolationHandle = SingleInstance.GetSingleInstanceHandleAsync(Name).GetAwaiter().GetResult();
// If there is another copy then pass it the command line and exit // If there is another copy then pass it the command line and exit
if (isolationHandle == null) if (isolationHandle == null)

View File

@@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Data.SqlServerCe; using System.Data.SqlServerCe;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using FeedCenter.Feeds;
namespace FeedCenter.Data; namespace FeedCenter.Data;

View File

@@ -3,6 +3,7 @@ using FeedCenter.Options;
using Realms; using Realms;
using System; using System;
using System.Linq; using System.Linq;
using FeedCenter.Feeds;
namespace FeedCenter; namespace FeedCenter;

View File

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net9.0-windows8.0</TargetFramework> <TargetFramework>net10.0-windows8.0</TargetFramework>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>false</UseWindowsForms> <UseWindowsForms>false</UseWindowsForms>
@@ -56,6 +56,10 @@
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" /> <PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /> <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\FeverClient\FeverClient.csproj" />
<ProjectReference Include="..\..\MinifluxClient\Library\MinifluxClient.csproj" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="Resources\Application.ico" /> <Resource Include="Resources\Application.ico" />
<Resource Include="Resources\Comments-edit.ico" /> <Resource Include="Resources\Comments-edit.ico" />

View File

@@ -1,3 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=Feeds/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=feeds/@EntryIndexedValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=mainwindow/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=mainwindow/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@@ -12,6 +12,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution", "Solution", "{14
..\README.md = ..\README.md ..\README.md = ..\README.md
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinifluxClient", "..\..\MinifluxClient\Library\MinifluxClient.csproj", "{6A48937F-AA57-8512-DA42-95ED79CED6D3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FeverClient", "..\..\FeverClient\FeverClient.csproj", "{8E502914-40F6-CD9C-769E-90B775D46088}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -39,6 +43,38 @@ Global
{BD3D12F2-DE23-4466-83B1-1EB617A877A4}.Release|x64.ActiveCfg = Release|x86 {BD3D12F2-DE23-4466-83B1-1EB617A877A4}.Release|x64.ActiveCfg = Release|x86
{BD3D12F2-DE23-4466-83B1-1EB617A877A4}.Release|x86.ActiveCfg = Release|Any CPU {BD3D12F2-DE23-4466-83B1-1EB617A877A4}.Release|x86.ActiveCfg = Release|Any CPU
{BD3D12F2-DE23-4466-83B1-1EB617A877A4}.Release|x86.Build.0 = Release|Any CPU {BD3D12F2-DE23-4466-83B1-1EB617A877A4}.Release|x86.Build.0 = Release|Any CPU
{6A48937F-AA57-8512-DA42-95ED79CED6D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6A48937F-AA57-8512-DA42-95ED79CED6D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A48937F-AA57-8512-DA42-95ED79CED6D3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{6A48937F-AA57-8512-DA42-95ED79CED6D3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{6A48937F-AA57-8512-DA42-95ED79CED6D3}.Debug|x64.ActiveCfg = Debug|Any CPU
{6A48937F-AA57-8512-DA42-95ED79CED6D3}.Debug|x64.Build.0 = Debug|Any CPU
{6A48937F-AA57-8512-DA42-95ED79CED6D3}.Debug|x86.ActiveCfg = Debug|Any CPU
{6A48937F-AA57-8512-DA42-95ED79CED6D3}.Debug|x86.Build.0 = Debug|Any CPU
{6A48937F-AA57-8512-DA42-95ED79CED6D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A48937F-AA57-8512-DA42-95ED79CED6D3}.Release|Any CPU.Build.0 = Release|Any CPU
{6A48937F-AA57-8512-DA42-95ED79CED6D3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{6A48937F-AA57-8512-DA42-95ED79CED6D3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{6A48937F-AA57-8512-DA42-95ED79CED6D3}.Release|x64.ActiveCfg = Release|Any CPU
{6A48937F-AA57-8512-DA42-95ED79CED6D3}.Release|x64.Build.0 = Release|Any CPU
{6A48937F-AA57-8512-DA42-95ED79CED6D3}.Release|x86.ActiveCfg = Release|Any CPU
{6A48937F-AA57-8512-DA42-95ED79CED6D3}.Release|x86.Build.0 = Release|Any CPU
{8E502914-40F6-CD9C-769E-90B775D46088}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8E502914-40F6-CD9C-769E-90B775D46088}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E502914-40F6-CD9C-769E-90B775D46088}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{8E502914-40F6-CD9C-769E-90B775D46088}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{8E502914-40F6-CD9C-769E-90B775D46088}.Debug|x64.ActiveCfg = Debug|Any CPU
{8E502914-40F6-CD9C-769E-90B775D46088}.Debug|x64.Build.0 = Debug|Any CPU
{8E502914-40F6-CD9C-769E-90B775D46088}.Debug|x86.ActiveCfg = Debug|Any CPU
{8E502914-40F6-CD9C-769E-90B775D46088}.Debug|x86.Build.0 = Debug|Any CPU
{8E502914-40F6-CD9C-769E-90B775D46088}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E502914-40F6-CD9C-769E-90B775D46088}.Release|Any CPU.Build.0 = Release|Any CPU
{8E502914-40F6-CD9C-769E-90B775D46088}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{8E502914-40F6-CD9C-769E-90B775D46088}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{8E502914-40F6-CD9C-769E-90B775D46088}.Release|x64.ActiveCfg = Release|Any CPU
{8E502914-40F6-CD9C-769E-90B775D46088}.Release|x64.Build.0 = Release|Any CPU
{8E502914-40F6-CD9C-769E-90B775D46088}.Release|x86.ActiveCfg = Release|Any CPU
{8E502914-40F6-CD9C-769E-90B775D46088}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -4,4 +4,5 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Kaczor/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> <s:Boolean x:Key="/Default/UserDictionary/Words/=Kaczor/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Miniflux/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@@ -4,6 +4,7 @@
xmlns:linkControl="clr-namespace:ChrisKaczor.Wpf.Controls;assembly=ChrisKaczor.Wpf.Controls.Link" xmlns:linkControl="clr-namespace:ChrisKaczor.Wpf.Controls;assembly=ChrisKaczor.Wpf.Controls.Link"
xmlns:controlBox="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.ControlBox" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:controlBox="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.ControlBox" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:feedCenter="clr-namespace:FeedCenter" xmlns:feedCenter="clr-namespace:FeedCenter"
xmlns:feeds="clr-namespace:FeedCenter.Feeds"
mc:Ignorable="d" mc:Ignorable="d"
x:Class="FeedCenter.FeedErrorWindow" x:Class="FeedCenter.FeedErrorWindow"
Title="{x:Static my:Resources.FeedErrorWindow}" Title="{x:Static my:Resources.FeedErrorWindow}"
@@ -46,7 +47,7 @@
HeadersVisibility="Column" HeadersVisibility="Column"
Background="{x:Null}" Background="{x:Null}"
CanUserSortColumns="True" CanUserSortColumns="True"
d:DataContext="{d:DesignInstance Type=feedCenter:Feed}" SelectionChanged="FeedDataGrid_SelectionChanged"> d:DataContext="{d:DesignInstance Type=feeds:Feed}" SelectionChanged="FeedDataGrid_SelectionChanged">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="{x:Static my:Resources.FeedNameColumnHeader}" <DataGridTextColumn Header="{x:Static my:Resources.FeedNameColumnHeader}"
Binding="{Binding Name}" Binding="{Binding Name}"

View File

@@ -5,6 +5,7 @@ using System.Windows;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Input; using System.Windows.Input;
using ChrisKaczor.InstalledBrowsers; using ChrisKaczor.InstalledBrowsers;
using FeedCenter.Feeds;
using FeedCenter.Options; using FeedCenter.Options;
using FeedCenter.Properties; using FeedCenter.Properties;

View File

@@ -1,6 +1,7 @@
using Serilog; using Serilog;
using System; using System;
using System.Xml; using System.Xml;
using FeedCenter.Feeds;
namespace FeedCenter.FeedParsers; namespace FeedCenter.FeedParsers;

View File

@@ -2,6 +2,7 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Xml; using System.Xml;
using FeedCenter.Feeds;
namespace FeedCenter.FeedParsers; namespace FeedCenter.FeedParsers;

View File

@@ -1,6 +1,7 @@
using FeedCenter.Xml; using FeedCenter.Xml;
using Serilog; using Serilog;
using System.Xml; using System.Xml;
using FeedCenter.Feeds;
namespace FeedCenter.FeedParsers; namespace FeedCenter.FeedParsers;

View File

@@ -2,6 +2,7 @@
using Serilog; using Serilog;
using System; using System;
using System.Xml; using System.Xml;
using FeedCenter.Feeds;
namespace FeedCenter.FeedParsers; namespace FeedCenter.FeedParsers;

View File

@@ -1,10 +1,11 @@
using Realms; using System;
using System;
using System.Collections; using System.Collections;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using Realms;
namespace FeedCenter; namespace FeedCenter.Feeds;
public class Account : RealmObject, INotifyDataErrorInfo public class Account : RealmObject, INotifyDataErrorInfo
{ {
@@ -37,6 +38,7 @@ public class Account : RealmObject, INotifyDataErrorInfo
{ {
AccountType.Fever => false, AccountType.Fever => false,
AccountType.GoogleReader => false, AccountType.GoogleReader => false,
AccountType.Miniflux => true,
AccountType.Local => true, AccountType.Local => true,
_ => throw new NotSupportedException() _ => throw new NotSupportedException()
}; };
@@ -45,6 +47,7 @@ public class Account : RealmObject, INotifyDataErrorInfo
{ {
AccountType.Fever => false, AccountType.Fever => false,
AccountType.GoogleReader => false, AccountType.GoogleReader => false,
AccountType.Miniflux => true,
AccountType.Local => true, AccountType.Local => true,
_ => throw new NotSupportedException() _ => throw new NotSupportedException()
}; };
@@ -158,21 +161,22 @@ public class Account : RealmObject, INotifyDataErrorInfo
return new Account { Name = DefaultName, Type = AccountType.Local }; return new Account { Name = DefaultName, Type = AccountType.Local };
} }
public int GetProgressSteps(FeedCenterEntities entities) public async Task<int> GetProgressSteps(Account account, AccountReadInput accountReadInput)
{ {
var progressSteps = Type switch var progressSteps = Type switch
{ {
// Delegate to the right reader based on the account type // Delegate to the right reader based on the account type
AccountType.Fever => new FeverReader().GetProgressSteps(entities), AccountType.Fever => await new FeverReader(account).GetProgressSteps(accountReadInput),
AccountType.GoogleReader => new GoogleReaderReader().GetProgressSteps(entities), AccountType.GoogleReader => await new GoogleReaderReader(account).GetProgressSteps(accountReadInput),
AccountType.Local => new LocalReader().GetProgressSteps(entities), AccountType.Miniflux => await new MinifluxReader(account).GetProgressSteps(accountReadInput),
AccountType.Local => await new LocalReader(account).GetProgressSteps(accountReadInput),
_ => throw new NotSupportedException() _ => throw new NotSupportedException()
}; };
return progressSteps; return progressSteps;
} }
public AccountReadResult Read(AccountReadInput accountReadInput) public async Task<AccountReadResult> Read(AccountReadInput accountReadInput)
{ {
// If not enabled then do nothing // If not enabled then do nothing
if (!Enabled) if (!Enabled)
@@ -189,14 +193,25 @@ public class Account : RealmObject, INotifyDataErrorInfo
return AccountReadResult.NotDue; return AccountReadResult.NotDue;
} }
var accountReadResult = Type switch AccountReadResult accountReadResult;
switch (Type)
{ {
// Delegate to the right reader based on the account type // Delegate to the right reader based on the account type
AccountType.Fever => new FeverReader().Read(this, accountReadInput), case AccountType.Fever:
AccountType.GoogleReader => new GoogleReaderReader().Read(this, accountReadInput), accountReadResult = await new FeverReader(this).Read(accountReadInput);
AccountType.Local => new LocalReader().Read(this, accountReadInput), break;
_ => throw new NotSupportedException() case AccountType.GoogleReader:
}; accountReadResult = await new GoogleReaderReader(this).Read(accountReadInput);
break;
case AccountType.Miniflux:
accountReadResult = await new MinifluxReader(this).Read(accountReadInput);
break;
case AccountType.Local:
accountReadResult = await new LocalReader(this).Read(accountReadInput);
break;
default:
throw new NotSupportedException();
}
return accountReadResult; return accountReadResult;
} }

View File

@@ -1,6 +1,6 @@
using System; using System;
namespace FeedCenter; namespace FeedCenter.Feeds;
public class AccountReadInput(FeedCenterEntities entities, Guid? feedId, bool forceRead, Action incrementProgress) public class AccountReadInput(FeedCenterEntities entities, Guid? feedId, bool forceRead, Action incrementProgress)
{ {

View File

@@ -1,4 +1,4 @@
namespace FeedCenter; namespace FeedCenter.Feeds;
public enum AccountReadResult public enum AccountReadResult
{ {

View File

@@ -1,8 +1,9 @@
namespace FeedCenter; namespace FeedCenter.Feeds;
public enum AccountType public enum AccountType
{ {
Local, Local,
Fever, Fever,
GoogleReader GoogleReader,
Miniflux
} }

View File

@@ -1,11 +1,11 @@
using JetBrains.Annotations; using System;
using Realms;
using System;
using System.Collections; using System.Collections;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using Realms;
namespace FeedCenter; namespace FeedCenter.Feeds;
public class Category : RealmObject, INotifyDataErrorInfo public class Category : RealmObject, INotifyDataErrorInfo
{ {

View File

@@ -3,7 +3,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
namespace FeedCenter; namespace FeedCenter.Feeds;
internal class DataErrorDictionary : Dictionary<string, List<string>> internal class DataErrorDictionary : Dictionary<string, List<string>>
{ {

View File

@@ -19,7 +19,7 @@ using JetBrains.Annotations;
using Realms; using Realms;
using Serilog; using Serilog;
namespace FeedCenter; namespace FeedCenter.Feeds;
public partial class Feed : RealmObject, INotifyDataErrorInfo public partial class Feed : RealmObject, INotifyDataErrorInfo
{ {

View File

@@ -1,12 +1,12 @@
using FeedCenter.Options; using System;
using Realms;
using System;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using FeedCenter.Options;
using Realms;
namespace FeedCenter; namespace FeedCenter.Feeds;
public partial class FeedItem : RealmObject public partial class FeedItem : RealmObject
{ {
@@ -90,7 +90,12 @@ public partial class FeedItem : RealmObject
{ {
case AccountType.Fever: case AccountType.Fever:
// Delegate to the right reader based on the account type // Delegate to the right reader based on the account type
await FeverReader.MarkFeedItemRead(feed.Account, RemoteId); await new FeverReader(feed.Account).MarkFeedItemRead(RemoteId);
break;
case AccountType.Miniflux:
// Delegate to the right reader based on the account type
await new MinifluxReader(feed.Account).MarkFeedItemRead(RemoteId);
break; break;
case AccountType.Local: case AccountType.Local:

View File

@@ -1,4 +1,4 @@
namespace FeedCenter; namespace FeedCenter.Feeds;
public enum FeedReadResult public enum FeedReadResult
{ {

View File

@@ -1,4 +1,4 @@
namespace FeedCenter; namespace FeedCenter.Feeds;
public enum FeedType public enum FeedType
{ {

View File

@@ -1,20 +1,26 @@
using System; using ChrisKaczor.FeverClient;
using System;
using System.Linq; using System.Linq;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using ChrisKaczor.FeverClient;
namespace FeedCenter; namespace FeedCenter.Feeds;
internal class FeverReader : IAccountReader internal class FeverReader(Account account) : IAccountReader
{ {
public int GetProgressSteps(FeedCenterEntities entities) public async Task<int> GetProgressSteps(AccountReadInput accountReadInput)
{ {
return 7; var apiKey = account.Authenticate ? GetApiKey(account) : string.Empty;
var feverClient = new FeverClient(account.Url, apiKey);
var feeds = await feverClient.GetFeeds();
return feeds.Count() * 2 + 5;
} }
public AccountReadResult Read(Account account, AccountReadInput accountReadInput) public async Task<AccountReadResult> Read(AccountReadInput accountReadInput)
{ {
var checkTime = DateTimeOffset.UtcNow; var checkTime = DateTimeOffset.UtcNow;
@@ -24,11 +30,11 @@ internal class FeverReader : IAccountReader
accountReadInput.IncrementProgress(); accountReadInput.IncrementProgress();
var feverFeeds = feverClient.GetFeeds().Result.ToList(); var feverFeeds = (await feverClient.GetFeeds()).ToList();
accountReadInput.IncrementProgress(); accountReadInput.IncrementProgress();
var allFeverFeedItems = feverClient.GetAllFeedItems().Result.ToList(); var allFeverFeedItems = (await feverClient.GetAllFeedItems()).ToList();
accountReadInput.IncrementProgress(); accountReadInput.IncrementProgress();
@@ -120,14 +126,14 @@ internal class FeverReader : IAccountReader
account.LastChecked = checkTime; account.LastChecked = checkTime;
transaction.Commit(); await transaction.CommitAsync();
accountReadInput.IncrementProgress(); accountReadInput.IncrementProgress();
return AccountReadResult.Success; return AccountReadResult.Success;
} }
public static async Task MarkFeedItemRead(Account account, string feedItemId) public async Task MarkFeedItemRead(string feedItemId)
{ {
var apiKey = account.Authenticate ? GetApiKey(account) : string.Empty; var apiKey = account.Authenticate ? GetApiKey(account) : string.Empty;

View File

@@ -1,19 +1,16 @@
using System; using System;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FeedCenter; namespace FeedCenter.Feeds;
internal class GoogleReaderReader : IAccountReader internal class GoogleReaderReader(Account account) : IAccountReader
{ {
public int GetProgressSteps(FeedCenterEntities entities) public Task<int> GetProgressSteps(AccountReadInput accountReadInput)
{ {
return 7; return Task.FromResult(7);
} }
public AccountReadResult Read(Account account, AccountReadInput accountReadInput) public async Task<AccountReadResult> Read(AccountReadInput accountReadInput)
{ {
var checkTime = DateTimeOffset.UtcNow; var checkTime = DateTimeOffset.UtcNow;
@@ -119,20 +116,22 @@ internal class GoogleReaderReader : IAccountReader
account.LastChecked = checkTime; account.LastChecked = checkTime;
transaction.Commit(); await transaction.CommitAsync();
accountReadInput.IncrementProgress(); accountReadInput.IncrementProgress();
return AccountReadResult.Success; return AccountReadResult.Success;
} }
public static async Task MarkFeedItemRead(Account account, string feedItemId) public Task MarkFeedItemRead(string feedItemId)
{ {
//var apiKey = account.Authenticate ? GetApiKey(account) : string.Empty; //var apiKey = account.Authenticate ? GetApiKey(account) : string.Empty;
//var feverClient = new FeverClient.FeverClient(account.Url, apiKey); //var feverClient = new FeverClient.FeverClient(account.Url, apiKey);
//await feverClient.MarkFeedItemAsRead(int.Parse(feedItemId)); //await feverClient.MarkFeedItemAsRead(int.Parse(feedItemId));
return Task.CompletedTask;
} }
//private static string GetApiKey(Account account) //private static string GetApiKey(Account account)

View File

@@ -1,7 +1,10 @@
namespace FeedCenter; using System.Threading.Tasks;
namespace FeedCenter.Feeds;
public interface IAccountReader public interface IAccountReader
{ {
public int GetProgressSteps(FeedCenterEntities entities); public Task<int> GetProgressSteps(AccountReadInput accountReadInput);
public AccountReadResult Read(Account account, AccountReadInput accountReadInput); public Task<AccountReadResult> Read(AccountReadInput accountReadInput);
public Task MarkFeedItemRead(string feedItemId);
} }

View File

@@ -1,19 +1,20 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
namespace FeedCenter; namespace FeedCenter.Feeds;
public class LocalReader : IAccountReader public class LocalReader(Account account) : IAccountReader
{ {
public int GetProgressSteps(FeedCenterEntities entities) public Task<int> GetProgressSteps(AccountReadInput accountReadInput)
{ {
var enabledFeedCount = entities.Feeds.Count(f => f.Account.Type == AccountType.Local && f.Enabled); var enabledFeedCount = accountReadInput.Entities.Feeds.Count(f => f.Account.Type == AccountType.Local && f.Enabled);
return enabledFeedCount; return Task.FromResult(enabledFeedCount);
} }
public AccountReadResult Read(Account account, AccountReadInput accountReadInput) public Task<AccountReadResult> Read(AccountReadInput accountReadInput)
{ {
var checkTime = DateTimeOffset.UtcNow; var checkTime = DateTimeOffset.UtcNow;
@@ -37,6 +38,11 @@ public class LocalReader : IAccountReader
accountReadInput.Entities.SaveChanges(() => account.LastChecked = checkTime); accountReadInput.Entities.SaveChanges(() => account.LastChecked = checkTime);
return AccountReadResult.Success; return Task.FromResult(AccountReadResult.Success);
}
public Task MarkFeedItemRead(string feedItemId)
{
throw new NotImplementedException();
} }
} }

View File

@@ -0,0 +1,146 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using ChrisKaczor.MinifluxClient;
namespace FeedCenter.Feeds;
internal class MinifluxReader(Account account) : IAccountReader
{
public async Task<int> GetProgressSteps(AccountReadInput accountReadInput)
{
var minifluxClient = new MinifluxClient(account.Url, account.Password);
int feedCount;
if (accountReadInput.FeedId.HasValue)
{
feedCount = 1;
}
else
{
var feeds = await minifluxClient.GetFeeds();
feedCount = feeds.Count();
}
return feedCount * 2 + 4;
}
public async Task<AccountReadResult> Read(AccountReadInput accountReadInput)
{
var checkTime = DateTimeOffset.UtcNow;
var minifluxClient = new MinifluxClient(account.Url, account.Password);
accountReadInput.IncrementProgress();
var localFeeds = accountReadInput.Entities.Feeds.ToList();
var remoteFeeds = (await minifluxClient.GetFeeds()).ToList();
if (accountReadInput.FeedId.HasValue)
{
localFeeds = localFeeds.Where(f => f.Id == accountReadInput.FeedId.Value).ToList();
remoteFeeds = remoteFeeds.Where(rf => rf.Id.ToString() == localFeeds.First().RemoteId).ToList();
}
accountReadInput.IncrementProgress();
var transaction = accountReadInput.Entities.BeginTransaction();
foreach (var remoteFeed in remoteFeeds)
{
var feed = accountReadInput.Entities.Feeds.FirstOrDefault(f => f.RemoteId == remoteFeed.Id.ToString() && f.Account.Id == account.Id);
if (feed == null)
{
feed = new Feed
{
Id = Guid.NewGuid(),
RemoteId = remoteFeed.Id.ToString(),
Title = remoteFeed.Title,
Source = remoteFeed.FeedUrl,
Link = remoteFeed.SiteUrl,
Account = account,
Name = remoteFeed.Title,
CategoryId = accountReadInput.Entities.DefaultCategory.Id,
Enabled = true,
CheckInterval = 0,
};
accountReadInput.Entities.Feeds.Add(feed);
}
feed.Name = remoteFeed.Title;
feed.Title = remoteFeed.Title;
feed.Link = remoteFeed.SiteUrl;
feed.Source = remoteFeed.FeedUrl;
feed.LastReadResult = FeedReadResult.Success;
feed.LastChecked = checkTime;
accountReadInput.IncrementProgress();
var sequence = 1;
var remoteFeedItems = (await minifluxClient.GetFeedEntries(remoteFeed.Id, SortField.PublishedAt, SortDirection.Descending)).ToList();
foreach (var remoteFeedItem in remoteFeedItems)
{
var feedItem = feed.Items.FirstOrDefault(f => f.RemoteId == remoteFeedItem.Id.ToString());
if (feedItem == null)
{
feedItem = new FeedItem
{
Id = Guid.NewGuid(),
RemoteId = remoteFeedItem.Id.ToString(),
Title = remoteFeedItem.Title,
Link = remoteFeedItem.Url,
Description = remoteFeedItem.Content,
BeenRead = remoteFeedItem.Status == "read",
FeedId = feed.Id,
Guid = Guid.NewGuid().ToString(),
Sequence = sequence++,
};
feed.Items.Add(feedItem);
}
feedItem.LastFound = checkTime;
feedItem.BeenRead = remoteFeedItem.Status == "read";
feedItem.Sequence = sequence++;
}
accountReadInput.IncrementProgress();
var feedItemsNotSeen = feed.Items.Where(fi => fi.LastFound != checkTime).ToList();
foreach (var feedItemNotSeen in feedItemsNotSeen)
{
feed.Items.Remove(feedItemNotSeen);
}
}
accountReadInput.IncrementProgress();
var feedsNotSeen = localFeeds.Where(f => f.Account.Id == account.Id && f.LastChecked != checkTime).ToList();
foreach (var feedNotSeen in feedsNotSeen)
{
accountReadInput.Entities.Feeds.Remove(feedNotSeen);
}
account.LastChecked = checkTime;
await transaction.CommitAsync();
accountReadInput.IncrementProgress();
return AccountReadResult.Success;
}
public async Task MarkFeedItemRead(string feedItemId)
{
var minifluxClient = new MinifluxClient(account.Url, account.Password);
await minifluxClient.MarkFeedEntries([long.Parse(feedItemId)], FeedEntryStatus.Read);
}
}

View File

@@ -1,4 +1,4 @@
namespace FeedCenter; namespace FeedCenter.Feeds;
public enum MultipleOpenAction public enum MultipleOpenAction
{ {

View File

@@ -3,6 +3,7 @@ using System;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using FeedCenter.Feeds;
namespace FeedCenter; namespace FeedCenter;

View File

@@ -3,6 +3,7 @@ using System;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Threading; using System.Threading;
using FeedCenter.Feeds;
namespace FeedCenter; namespace FeedCenter;

View File

@@ -38,7 +38,7 @@ public partial class MainWindow
return; return;
// Get the feed item // Get the feed item
var feedItem = (FeedItem) ((ListBoxItem) sender).DataContext; var feedItem = (Feeds.FeedItem) ((ListBoxItem) sender).DataContext;
// Remove the item from the list // Remove the item from the list
LinkTextList.Items.Remove(feedItem); LinkTextList.Items.Remove(feedItem);
@@ -50,7 +50,7 @@ public partial class MainWindow
private async void HandleItemMouseDoubleClick(object sender, MouseButtonEventArgs e) private async void HandleItemMouseDoubleClick(object sender, MouseButtonEventArgs e)
{ {
// Get the feed item // Get the feed item
var feedItem = (FeedItem) ((ListBoxItem) sender).DataContext; var feedItem = (Feeds.FeedItem) ((ListBoxItem) sender).DataContext;
// Try to open the item link // Try to open the item link
if (!InstalledBrowser.OpenLink(Settings.Default.Browser, feedItem.Link)) if (!InstalledBrowser.OpenLink(Settings.Default.Browser, feedItem.Link))
@@ -104,7 +104,7 @@ public partial class MainWindow
var menuItem = (MenuItem) sender; var menuItem = (MenuItem) sender;
// Get the feed from the menu item tab // Get the feed from the menu item tab
var feed = (Feed) menuItem.Tag; var feed = (Feeds.Feed) menuItem.Tag;
// Loop over all feeds and look for the index of the new one // Loop over all feeds and look for the index of the new one
var feedIndex = 0; var feedIndex = 0;

View File

@@ -1,38 +1,19 @@
using ChrisKaczor.ApplicationUpdate; using ChrisKaczor.ApplicationUpdate;
using FeedCenter.Feeds;
using FeedCenter.Properties; using FeedCenter.Properties;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
namespace FeedCenter; namespace FeedCenter;
public partial class MainWindow public partial class MainWindow
{ {
private BackgroundWorker _feedReadWorker; private bool _reading;
private class FeedReadWorkerInput
{
public bool ForceRead { get; }
public Guid? FeedId { get; }
public FeedReadWorkerInput()
{
}
public FeedReadWorkerInput(bool forceRead)
{
ForceRead = forceRead;
}
public FeedReadWorkerInput(bool forceRead, Guid? feedId)
{
ForceRead = forceRead;
FeedId = feedId;
}
}
private void SetProgressMode(bool showProgress, int maximum) private void SetProgressMode(bool showProgress, int maximum)
{ {
@@ -49,55 +30,72 @@ public partial class MainWindow
} }
} }
private void ReadCurrentFeed(bool forceRead = false) private async void ReadCurrentFeed(bool forceRead = false)
{ {
// Don't read if we're already working try
if (_feedReadWorker.IsBusy) {
return; // Don't read if we're already working
if (_reading)
return;
// Don't read if there is nothing to read _reading = true;
if (!_database.Feeds.Any())
return;
// Switch to progress mode // Don't read if there is nothing to read
SetProgressMode(true, 1); if (!_database.Feeds.Any())
return;
// Create the input class var accountReadInput = new AccountReadInput(_database, _currentFeed.Id, forceRead, () => { });
var workerInput = new FeedReadWorkerInput(forceRead, _currentFeed.Id);
// Start the worker // Switch to progress mode
_feedReadWorker.RunWorkerAsync(workerInput); SetProgressMode(true, await _currentFeed.Account.GetProgressSteps(_currentFeed.Account, accountReadInput));
// Start reading
await HandleFeedReadWorkerStart(forceRead, _currentFeed.Id);
}
catch (Exception exception)
{
HandleException(exception);
}
} }
private void ReadFeeds(bool forceRead = false) private async Task ReadFeeds(bool forceRead = false)
{ {
// Don't read if we're already working // Don't read if we're already working
if (_feedReadWorker.IsBusy) if (_reading)
return; return;
_reading = true;
// Don't read if there is nothing to read // Don't read if there is nothing to read
if (!_database.Accounts.Any()) if (!_database.Accounts.Any())
return; return;
var progressSteps = _database.Accounts.Sum(a => a.GetProgressSteps(_database)); var accountReadInput = new AccountReadInput(_database, null, forceRead, () => { });
// Calculate total progress steps
var progressSteps = 0;
foreach (var account in _database.Accounts)
{
progressSteps += await account.GetProgressSteps(account, accountReadInput);
}
// Switch to progress mode // Switch to progress mode
SetProgressMode(true, progressSteps); SetProgressMode(true, progressSteps);
// Create the input class // Start reading
var workerInput = new FeedReadWorkerInput(forceRead); await HandleFeedReadWorkerStart(forceRead, null);
// Start the worker
_feedReadWorker.RunWorkerAsync(workerInput);
} }
private void HandleFeedReadWorkerProgressChanged(object sender, ProgressChangedEventArgs e) private void IncrementProgress()
{ {
Debug.Assert(FeedReadProgress.Value + 1 <= FeedReadProgress.Maximum);
// Set progress // Set progress
FeedReadProgress.Value = e.ProgressPercentage; FeedReadProgress.Value++;
} }
private void HandleFeedReadWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) private void CompleteRead()
{ {
// Refresh the database to current settings // Refresh the database to current settings
ResetDatabase(); ResetDatabase();
@@ -119,6 +117,8 @@ public partial class MainWindow
NewVersionLink.Visibility = Visibility.Visible; NewVersionLink.Visibility = Visibility.Visible;
UpdateErrorLink(); UpdateErrorLink();
_reading = false;
} }
private void UpdateErrorLink() private void UpdateErrorLink()
@@ -134,98 +134,61 @@ public partial class MainWindow
: string.Format(Properties.Resources.FeedErrorsLink, feedErrorCount); : string.Format(Properties.Resources.FeedErrorsLink, feedErrorCount);
} }
private static void HandleFeedReadWorkerStart(object sender, DoWorkEventArgs e) private async Task HandleFeedReadWorkerStart(bool forceRead, Guid? feedId)
{ {
// Create a new database instance for just this thread try
var database = new FeedCenterEntities();
// Get the worker
var worker = (BackgroundWorker)sender;
// Get the input information
var workerInput = (FeedReadWorkerInput)e.Argument ?? new FeedReadWorkerInput();
// Setup for progress
var currentProgress = 0;
var accountsToRead = new List<Account>();
// If we have a single feed then get the account for that feed
if (workerInput.FeedId != null)
{ {
var feed = database.Feeds.FirstOrDefault(f => f.Id == workerInput.FeedId); // Create a new database instance for just this thread
var database = new FeedCenterEntities();
if (feed != null) var accountsToRead = new List<Account>();
accountsToRead.Add(feed.Account);
}
else
{
// Otherwise get all accounts
accountsToRead.AddRange(database.Accounts);
}
var incrementProgress = () => // If we have a single feed then get the account for that feed
{ if (feedId != null)
// Increment progress {
currentProgress += 1; var feed = database.Feeds.FirstOrDefault(f => f.Id == feedId);
if (feed != null)
accountsToRead.Add(feed.Account);
}
else
{
// Otherwise get all accounts
accountsToRead.AddRange(database.Accounts);
}
// Loop over each account and read it
foreach (var account in accountsToRead)
{
var accountReadInput = new AccountReadInput(database, feedId, forceRead, IncrementProgress);
await account.Read(accountReadInput);
}
// Report progress // Report progress
worker.ReportProgress(currentProgress); IncrementProgress();
};
// Loop over each account and read it // See if we're due for a version check
foreach (var account in accountsToRead) if (UpdateCheck.LocalVersion.Major > 0 && DateTime.Now - Settings.Default.LastVersionCheck >= Settings.Default.VersionCheckInterval)
{ {
var accountReadInput = new AccountReadInput(database, workerInput.FeedId, workerInput.ForceRead, incrementProgress); // Get the update information
await UpdateCheck.CheckForUpdate(Settings.Default.IncludePrerelease);
account.Read(accountReadInput); // Update the last check time
Settings.Default.LastVersionCheck = DateTime.Now;
}
// Report progress
IncrementProgress();
// Sleep for a little bit so the user can see the update
Thread.Sleep(Settings.Default.ProgressSleepInterval * 3);
CompleteRead();
} }
catch (Exception exception)
//// Create the list of feeds to read
//var feedsToRead = new List<Feed>();
//// If we have a single feed then add it to the list - otherwise add them all
//if (workerInput.FeedId != null)
// feedsToRead.Add(database.Feeds.First(feed => feed.Id == workerInput.FeedId));
//else
// feedsToRead.AddRange(database.Feeds);
//// Loop over each feed and read it
//foreach (var feed in feedsToRead)
//{
// // Read the feed
// database.SaveChanges(() => feed.Read(workerInput.ForceRead));
// // Increment progress
// currentProgress += 1;
// // Report progress
// worker.ReportProgress(currentProgress);
//}
// Increment progress
currentProgress += 1;
// Report progress
worker.ReportProgress(currentProgress);
// See if we're due for a version check
if (DateTime.Now - Settings.Default.LastVersionCheck >= Settings.Default.VersionCheckInterval)
{ {
// Get the update information HandleException(exception);
UpdateCheck.CheckForUpdate(Settings.Default.IncludePrerelease).Wait();
// Update the last check time
Settings.Default.LastVersionCheck = DateTime.Now;
} }
// Increment progress
currentProgress += 1;
// Report progress
worker.ReportProgress(currentProgress);
// Sleep for a little bit so the user can see the update
Thread.Sleep(Settings.Default.ProgressSleepInterval * 3);
} }
} }

View File

@@ -1,5 +1,6 @@
using ChrisKaczor.ApplicationUpdate; using ChrisKaczor.ApplicationUpdate;
using ChrisKaczor.Wpf.Application; using ChrisKaczor.Wpf.Application;
using FeedCenter.Feeds;
using FeedCenter.Properties; using FeedCenter.Properties;
using Serilog; using Serilog;
using System; using System;
@@ -29,7 +30,6 @@ public partial class MainWindow : IDisposable
public void Dispose() public void Dispose()
{ {
_mainTimer?.Dispose(); _mainTimer?.Dispose();
_feedReadWorker?.Dispose();
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
@@ -66,12 +66,6 @@ public partial class MainWindow : IDisposable
: Brushes.Black; : Brushes.Black;
HeaderLabel.Foreground = LinkTextList.Foreground; HeaderLabel.Foreground = LinkTextList.Foreground;
// Create the background worker that does the actual reading
_feedReadWorker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true };
_feedReadWorker.DoWork += HandleFeedReadWorkerStart;
_feedReadWorker.ProgressChanged += HandleFeedReadWorkerProgressChanged;
_feedReadWorker.RunWorkerCompleted += HandleFeedReadWorkerCompleted;
// Set up the database // Set up the database
_database = new FeedCenterEntities(); _database = new FeedCenterEntities();
@@ -88,13 +82,16 @@ public partial class MainWindow : IDisposable
// Initialize the feed display // Initialize the feed display
InitializeDisplay(); InitializeDisplay();
// Check for update if (UpdateCheck.LocalVersion.Major > 0)
if (Settings.Default.CheckVersionAtStartup) {
await UpdateCheck.CheckForUpdate(Settings.Default.IncludePrerelease); // Check for update
if (Settings.Default.CheckVersionAtStartup)
await UpdateCheck.CheckForUpdate(Settings.Default.IncludePrerelease);
// Show the link if updates are available // Show the link if updates are available
if (UpdateCheck.UpdateAvailable) if (UpdateCheck.UpdateAvailable)
NewVersionLink.Visibility = Visibility.Visible; NewVersionLink.Visibility = Visibility.Visible;
}
Log.Logger.Information("MainForm creation finished"); Log.Logger.Information("MainForm creation finished");
} }

View File

@@ -38,29 +38,36 @@ public partial class MainWindow
_mainTimer?.Stop(); _mainTimer?.Stop();
} }
private void HandleMainTimerElapsed(object sender, EventArgs e) private async void HandleMainTimerElapsed(object sender, EventArgs e)
{ {
_dispatcher.Invoke(() => try
{ {
// If the background worker is busy then don't do anything await _dispatcher.Invoke(async () =>
if (_feedReadWorker.IsBusy) {
return; // If the background worker is busy then don't do anything
if (_reading)
return;
// Stop the timer for now // Stop the timer for now
StopTimer(); StopTimer();
// Move to the next feed if the scroll interval has expired and the mouse isn't hovering // Move to the next feed if the scroll interval has expired and the mouse isn't hovering
if (LinkTextList.IsMouseOver) if (LinkTextList.IsMouseOver)
_lastFeedDisplay = DateTime.Now; _lastFeedDisplay = DateTime.Now;
else if (DateTime.Now - _lastFeedDisplay >= Settings.Default.FeedScrollInterval) else if (DateTime.Now - _lastFeedDisplay >= Settings.Default.FeedScrollInterval)
NextFeed(); NextFeed();
// Check to see if we should try to read the feeds // Check to see if we should try to read the feeds
if (DateTime.Now - _lastFeedRead >= Settings.Default.FeedCheckInterval) if (DateTime.Now - _lastFeedRead >= Settings.Default.FeedCheckInterval)
ReadFeeds(); await ReadFeeds();
// Get the timer going again // Get the timer going again
StartTimer(); StartTimer();
}); });
}
catch (Exception exception)
{
HandleException(exception);
}
} }
} }

View File

@@ -9,6 +9,7 @@ using System.Threading.Tasks;
using System.Web.UI; using System.Web.UI;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using FeedCenter.Feeds;
using Serilog; using Serilog;
using Serilog.Events; using Serilog.Events;
@@ -75,7 +76,7 @@ public partial class MainWindow
UpdateErrorLink(); UpdateErrorLink();
} }
private static void HandleException(Exception exception) internal static void HandleException(Exception exception)
{ {
Log.Logger.Write(LogEventLevel.Debug, exception, ""); Log.Logger.Write(LogEventLevel.Debug, exception, "");
} }
@@ -109,19 +110,33 @@ public partial class MainWindow
UpdateErrorLink(); UpdateErrorLink();
} }
private void HandleRefreshMenuItemClick(object sender, RoutedEventArgs e) private async void HandleRefreshMenuItemClick(object sender, RoutedEventArgs e)
{ {
var menuItem = (MenuItem) e.Source; try
{
var menuItem = (MenuItem) e.Source;
if (Equals(menuItem, MenuRefresh)) if (Equals(menuItem, MenuRefresh))
ReadCurrentFeed(true); ReadCurrentFeed(true);
else if (Equals(menuItem, MenuRefreshAll)) else if (Equals(menuItem, MenuRefreshAll))
ReadFeeds(true); await ReadFeeds(true);
}
catch (Exception exception)
{
HandleException(exception);
}
} }
private void HandleRefreshToolbarButtonClick(object sender, RoutedEventArgs e) private async void HandleRefreshToolbarButtonClick(object sender, RoutedEventArgs e)
{ {
ReadFeeds(true); try
{
await ReadFeeds(true);
}
catch (Exception exception)
{
HandleException(exception);
}
} }
private async void HandleOpenAllMenuItemClick(object sender, RoutedEventArgs e) private async void HandleOpenAllMenuItemClick(object sender, RoutedEventArgs e)

View File

@@ -76,13 +76,6 @@ public partial class MainWindow
{ {
base.OnClosing(e); base.OnClosing(e);
// Ditch the worker
if (_feedReadWorker != null)
{
_feedReadWorker.CancelAsync();
_feedReadWorker.Dispose();
}
// Get rid of the timer // Get rid of the timer
TerminateTimer(); TerminateTimer();

View File

@@ -1,24 +1,29 @@
using System.Collections.Generic; using System.Collections.Generic;
using FeedCenter.Feeds;
namespace FeedCenter.Options namespace FeedCenter.Options;
public class AccountTypeItem
{ {
public class AccountTypeItem public AccountType AccountType { get; set; }
{ public string Name { get; set; }
public AccountType AccountType { get; set; }
public string Name { get; set; }
public static List<AccountTypeItem> AccountTypes => public static List<AccountTypeItem> AccountTypes =>
[ [
new() new()
{ {
Name = Properties.Resources.AccountTypeFever, Name = Properties.Resources.AccountTypeFever,
AccountType = AccountType.Fever AccountType = AccountType.Fever
}, },
//new() //new()
//{ //{
// Name = Properties.Resources.AccountTypeGoogleReader, // Name = Properties.Resources.AccountTypeGoogleReader,
// AccountType = AccountType.GoogleReader // AccountType = AccountType.GoogleReader
//} //}
]; new()
} {
Name = Properties.Resources.AccountTypeMiniflux,
AccountType = AccountType.Miniflux
}
];
} }

View File

@@ -2,6 +2,7 @@ using System;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Windows.Data; using System.Windows.Data;
using FeedCenter.Feeds;
namespace FeedCenter.Options; namespace FeedCenter.Options;

View File

@@ -4,10 +4,11 @@
xmlns:properties="clr-namespace:FeedCenter.Properties" xmlns:properties="clr-namespace:FeedCenter.Properties"
xmlns:feedCenter="clr-namespace:FeedCenter" xmlns:feedCenter="clr-namespace:FeedCenter"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d:DataContext="{d:DesignInstance Type=feedCenter:Account}" d:DataContext="{d:DesignInstance Type=feeds:Account}"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:options="clr-namespace:FeedCenter.Options" xmlns:options="clr-namespace:FeedCenter.Options"
xmlns:feeds="clr-namespace:FeedCenter.Feeds"
mc:Ignorable="d" mc:Ignorable="d"
Title="AccountWindow" Title="AccountWindow"
Height="350" Height="350"

View File

@@ -1,6 +1,7 @@
using ChrisKaczor.Wpf.Validation; using ChrisKaczor.Wpf.Validation;
using FeedCenter.Feeds;
using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Threading; using System.Windows.Threading;
@@ -33,46 +34,46 @@ public partial class AccountWindow
return ShowDialog(); return ShowDialog();
} }
private void HandleOkayButtonClick(object sender, RoutedEventArgs e) private async void HandleOkayButtonClick(object sender, RoutedEventArgs e)
{ {
var transaction = _entities.BeginTransaction(); try
if (!this.IsValid(OptionsTabControl))
{ {
transaction.Rollback(); var transaction = _entities.BeginTransaction();
return;
}
if (_isNew) if (!this.IsValid(OptionsTabControl))
{
_entities.Accounts.Add(_account);
}
transaction.Commit();
var accountId = _account.Id;
AccountReadProgressBar.Value = 0;
AccountReadProgressBar.Maximum = _account.GetProgressSteps(_entities) + 1;
AccountReadProgress.Visibility = Visibility.Visible;
ButtonPanel.Visibility = Visibility.Collapsed;
var dispatcher = Dispatcher.CurrentDispatcher;
Task.Run(() =>
{
var entities = new FeedCenterEntities();
var account = entities.Accounts.First(a => a.Id == accountId);
var accountReadInput = new AccountReadInput(entities, null, true, () => dispatcher.Invoke(() => AccountReadProgressBar.Value++));
account.Read(accountReadInput);
dispatcher.Invoke(() =>
{ {
DialogResult = true; transaction.Rollback();
return;
}
Close(); if (_isNew)
}); {
}); _entities.Accounts.Add(_account);
}
await transaction.CommitAsync();
var accountId = _account.Id;
var accountReadInput = new AccountReadInput(_entities, null, true, () => AccountReadProgressBar.Value++);
AccountReadProgressBar.Value = 0;
AccountReadProgressBar.Maximum = await _account.GetProgressSteps(_account, accountReadInput);
AccountReadProgress.Visibility = Visibility.Visible;
ButtonPanel.Visibility = Visibility.Collapsed;
//var entities = new FeedCenterEntities();
var account = _entities.Accounts.First(a => a.Id == accountId);
await account.Read(accountReadInput);
DialogResult = true;
Close();
}
catch (Exception exception)
{
MainWindow.HandleException(exception);
}
} }
} }

View File

@@ -7,6 +7,7 @@
xmlns:properties="clr-namespace:FeedCenter.Properties" xmlns:properties="clr-namespace:FeedCenter.Properties"
xmlns:controls="clr-namespace:ChrisKaczor.Wpf.Controls;assembly=ChrisKaczor.Wpf.Controls.Link" xmlns:controls="clr-namespace:ChrisKaczor.Wpf.Controls;assembly=ChrisKaczor.Wpf.Controls.Link"
xmlns:feedCenter="clr-namespace:FeedCenter" xmlns:feedCenter="clr-namespace:FeedCenter"
xmlns:feeds="clr-namespace:FeedCenter.Feeds"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="311" d:DesignHeight="311"
d:DesignWidth="425"> d:DesignWidth="425">
@@ -46,7 +47,7 @@
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"
AllowDrop="True" AllowDrop="True"
Background="{x:Null}" Background="{x:Null}"
d:DataContext="{d:DesignInstance feedCenter:Account }"> d:DataContext="{d:DesignInstance feeds:Account }">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}" <DataGridTextColumn Binding="{Binding Name}"
Header="{x:Static properties:Resources.AccountNameColumnHeader}" Header="{x:Static properties:Resources.AccountNameColumnHeader}"

View File

@@ -4,6 +4,7 @@ using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Input; using System.Windows.Input;
using FeedCenter.Feeds;
namespace FeedCenter.Options; namespace FeedCenter.Options;

View File

@@ -9,6 +9,7 @@
xmlns:controls="clr-namespace:ChrisKaczor.Wpf.Controls;assembly=ChrisKaczor.Wpf.Controls.Link" xmlns:controls="clr-namespace:ChrisKaczor.Wpf.Controls;assembly=ChrisKaczor.Wpf.Controls.Link"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:options="clr-namespace:FeedCenter.Options" xmlns:options="clr-namespace:FeedCenter.Options"
xmlns:feeds="clr-namespace:FeedCenter.Feeds"
WindowStartupLocation="CenterOwner" WindowStartupLocation="CenterOwner"
Icon="/FeedCenter;component/Resources/Application.ico" Icon="/FeedCenter;component/Resources/Application.ico"
FocusManager.FocusedElement="{Binding ElementName=FeedLinkFilterText}"> FocusManager.FocusedElement="{Binding ElementName=FeedLinkFilterText}">
@@ -99,9 +100,9 @@
mah:TextBoxHelper.Watermark="{x:Static my:Resources.openLabel}" mah:TextBoxHelper.Watermark="{x:Static my:Resources.openLabel}"
IsEnabled="{Binding ElementName=OpenCheckBox, Path=IsChecked}"> IsEnabled="{Binding ElementName=OpenCheckBox, Path=IsChecked}">
<ComboBoxItem Content="{x:Static my:Resources.openAllMultipleToolbarButton}" <ComboBoxItem Content="{x:Static my:Resources.openAllMultipleToolbarButton}"
Tag="{x:Static feedCenter:MultipleOpenAction.IndividualPages}" /> Tag="{x:Static feeds:MultipleOpenAction.IndividualPages}" />
<ComboBoxItem Content="{x:Static my:Resources.openAllSingleToolbarButton}" <ComboBoxItem Content="{x:Static my:Resources.openAllSingleToolbarButton}"
Tag="{x:Static feedCenter:MultipleOpenAction.SinglePage}" /> Tag="{x:Static feeds:MultipleOpenAction.SinglePage}" />
</ComboBox> </ComboBox>
</Grid> </Grid>
<StackPanel Grid.Column="0" <StackPanel Grid.Column="0"

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using FeedCenter.Feeds;
namespace FeedCenter.Options; namespace FeedCenter.Options;

View File

@@ -9,7 +9,8 @@
xmlns:controls="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.ControlBox" xmlns:controls="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.ControlBox"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:options="clr-namespace:FeedCenter.Options" xmlns:options="clr-namespace:FeedCenter.Options"
d:DataContext="{d:DesignInstance Type=feedCenter:Category}" xmlns:feeds="clr-namespace:FeedCenter.Feeds"
d:DataContext="{d:DesignInstance Type=feeds:Category}"
Title="CategoryWindow" Title="CategoryWindow"
Width="300" Width="300"
ResizeMode="NoResize" ResizeMode="NoResize"

View File

@@ -1,5 +1,6 @@
using ChrisKaczor.Wpf.Validation; using ChrisKaczor.Wpf.Validation;
using System.Windows; using System.Windows;
using FeedCenter.Feeds;
namespace FeedCenter.Options; namespace FeedCenter.Options;

View File

@@ -1,6 +1,3 @@
namespace FeedCenter.Options namespace FeedCenter.Options;
{
public class CheckedFeedListItem : CheckedListItem<Feed> public class CheckedFeedListItem : CheckedListItem<Feeds.Feed>;
{
}
}

View File

@@ -4,10 +4,11 @@
xmlns:properties="clr-namespace:FeedCenter.Properties" xmlns:properties="clr-namespace:FeedCenter.Properties"
xmlns:feedCenter="clr-namespace:FeedCenter" xmlns:feedCenter="clr-namespace:FeedCenter"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d:DataContext="{d:DesignInstance Type=feedCenter:Feed}" d:DataContext="{d:DesignInstance Type=feeds:Feed}"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:options="clr-namespace:FeedCenter.Options" xmlns:options="clr-namespace:FeedCenter.Options"
xmlns:feeds="clr-namespace:FeedCenter.Feeds"
mc:Ignorable="d" mc:Ignorable="d"
Title="FeedWindow" Title="FeedWindow"
Height="350" Height="350"
@@ -90,9 +91,9 @@
mah:TextBoxHelper.UseFloatingWatermark="True" mah:TextBoxHelper.UseFloatingWatermark="True"
mah:TextBoxHelper.Watermark="{x:Static properties:Resources.openLabel}"> mah:TextBoxHelper.Watermark="{x:Static properties:Resources.openLabel}">
<ComboBoxItem Content="{x:Static properties:Resources.openAllSingleToolbarButton}" <ComboBoxItem Content="{x:Static properties:Resources.openAllSingleToolbarButton}"
Tag="{x:Static feedCenter:MultipleOpenAction.SinglePage}" /> Tag="{x:Static feeds:MultipleOpenAction.SinglePage}" />
<ComboBoxItem Content="{x:Static properties:Resources.openAllMultipleToolbarButton}" <ComboBoxItem Content="{x:Static properties:Resources.openAllMultipleToolbarButton}"
Tag="{x:Static feedCenter:MultipleOpenAction.IndividualPages}" /> Tag="{x:Static feeds:MultipleOpenAction.IndividualPages}" />
</ComboBox> </ComboBox>
<ComboBox Name="UserAgentComboBox" <ComboBox Name="UserAgentComboBox"
mah:TextBoxHelper.UseFloatingWatermark="True" mah:TextBoxHelper.UseFloatingWatermark="True"

View File

@@ -14,7 +14,7 @@ public partial class FeedWindow
InitializeComponent(); InitializeComponent();
} }
public bool? Display(Feed feed, Window owner) public bool? Display(Feeds.Feed feed, Window owner)
{ {
CategoryComboBox.ItemsSource = _entities.Categories; CategoryComboBox.ItemsSource = _entities.Categories;

View File

@@ -7,6 +7,7 @@
xmlns:properties="clr-namespace:FeedCenter.Properties" xmlns:properties="clr-namespace:FeedCenter.Properties"
xmlns:controls="clr-namespace:ChrisKaczor.Wpf.Controls;assembly=ChrisKaczor.Wpf.Controls.Link" xmlns:controls="clr-namespace:ChrisKaczor.Wpf.Controls;assembly=ChrisKaczor.Wpf.Controls.Link"
xmlns:feedCenter="clr-namespace:FeedCenter" xmlns:feedCenter="clr-namespace:FeedCenter"
xmlns:feeds="clr-namespace:FeedCenter.Feeds"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="311" d:DesignHeight="311"
d:DesignWidth="425"> d:DesignWidth="425">
@@ -45,7 +46,7 @@
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"
AllowDrop="True" AllowDrop="True"
Background="{x:Null}" Background="{x:Null}"
d:DataContext="{d:DesignInstance feedCenter:Category }"> d:DataContext="{d:DesignInstance feeds:Category }">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}" <DataGridTextColumn Binding="{Binding Name}"
Header="{x:Static properties:Resources.CategoryNameColumnHeader}" Header="{x:Static properties:Resources.CategoryNameColumnHeader}"
@@ -80,7 +81,7 @@
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"
Background="{x:Null}" Background="{x:Null}"
SelectionChanged="HandleFeedDataGridSelectionChanged" SelectionChanged="HandleFeedDataGridSelectionChanged"
d:DataContext="{d:DesignInstance feedCenter:Feed }"> d:DataContext="{d:DesignInstance feeds:Feed }">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}" <DataGridTextColumn Binding="{Binding Name}"
Header="{x:Static properties:Resources.FeedNameColumnHeader}" Header="{x:Static properties:Resources.FeedNameColumnHeader}"

View File

@@ -7,6 +7,7 @@ using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Input; using System.Windows.Input;
using System.Xml; using System.Xml;
using FeedCenter.Feeds;
namespace FeedCenter.Options; namespace FeedCenter.Options;

View File

@@ -12,7 +12,7 @@ public class UserAgentItem
{ {
new UserAgentItem new UserAgentItem
{ {
Caption = Properties.Resources.ApplicationUserAgentCaption, Caption = Resources.ApplicationUserAgentCaption,
UserAgent = string.Empty UserAgent = string.Empty
}, },
new UserAgentItem new UserAgentItem

View File

@@ -25,5 +25,5 @@ using System.Windows;
[assembly: NeutralResourcesLanguage("en-US")] [assembly: NeutralResourcesLanguage("en-US")]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
[assembly: AssemblyVersion("1.1.0.0")] [assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyFileVersion("0.0.0.0")]

View File

@@ -19,7 +19,7 @@ namespace FeedCenter.Properties {
// class via a tool like ResGen or Visual Studio. // class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen // To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project. // with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources { public class Resources {
@@ -141,6 +141,15 @@ namespace FeedCenter.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Miniflux.
/// </summary>
public static string AccountTypeMiniflux {
get {
return ResourceManager.GetString("AccountTypeMiniflux", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to URL. /// Looks up a localized string similar to URL.
/// </summary> /// </summary>

View File

@@ -614,5 +614,8 @@ All feeds currently in category "{0}" will be moved to the default category.</va
</data> </data>
<data name="includePrereleaseCheckBox" xml:space="preserve"> <data name="includePrereleaseCheckBox" xml:space="preserve">
<value>Include _prerelease</value> <value>Include _prerelease</value>
</data> </data>
<data name="AccountTypeMiniflux" xml:space="preserve">
<value>Miniflux</value>
</data>
</root> </root>