Skip to content

Commit

Permalink
bugfix and upgrade to v2.0.2.0. (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
nodew authored Nov 1, 2024
1 parent 5d78161 commit 3f6baf4
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 39 deletions.
2 changes: 1 addition & 1 deletion PocketClient.Core/Models/Author.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public string Name
get; set;
}

public string Url
public string? Url
{
get; set;
}
Expand Down
8 changes: 4 additions & 4 deletions PocketClient.Core/PocketClient.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.10" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows10.0.22000.0</TargetFramework>
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
<RootNamespace>PocketClient.Desktop.Tests.MSTest</RootNamespace>
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
Expand All @@ -11,13 +11,13 @@
<ProjectPriFileName>resources.pri</ProjectPriFileName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PocketClient.Desktop\PocketClient.Desktop.csproj" />
Expand Down
8 changes: 8 additions & 0 deletions PocketClient.Desktop/Models/Messages/SyncFailureMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace PocketClient.Desktop.Models;

public class SyncFailureMessage(string reason, Exception ex)
{
public string Reason { get; set; } = reason;

public Exception Exception { get; set; } = ex;
}
2 changes: 1 addition & 1 deletion PocketClient.Desktop/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Identity
Name="51617AD91681C.PocketforWindows"
Publisher="CN=49D5850C-0DAE-44D6-A062-D909A189CEDB"
Version="2.0.1.0" />
Version="2.0.2.0" />

<Properties>
<DisplayName>Nuts - Save &amp; Read</DisplayName>
Expand Down
32 changes: 16 additions & 16 deletions PocketClient.Desktop/PocketClient.Desktop.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows10.0.22000.0</TargetFramework>
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<RootNamespace>PocketClient.Desktop</RootNamespace>
<ApplicationIcon>Assets/WindowIcon.ico</ApplicationIcon>
Expand Down Expand Up @@ -31,29 +31,29 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="CommunityToolkit.WinUI.Collections" Version="8.0.240109" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.0.240109" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.0.240109" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.TokenizingTextBox" Version="8.0.240109" />
<PackageReference Include="CommunityToolkit.WinUI.Converters" Version="8.0.240109" />
<PackageReference Include="CommunityToolkit.WinUI.Extensions" Version="8.0.240109" />
<PackageReference Include="CommunityToolkit.WinUI.Helpers" Version="8.0.240109" />
<PackageReference Include="CommunityToolkit.WinUI.Triggers" Version="8.0.240109" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
<PackageReference Include="CommunityToolkit.WinUI.Collections" Version="8.1.240916" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.1.240916" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.1.240916" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.TokenizingTextBox" Version="8.1.240916" />
<PackageReference Include="CommunityToolkit.WinUI.Converters" Version="8.1.240916" />
<PackageReference Include="CommunityToolkit.WinUI.Extensions" Version="8.1.240916" />
<PackageReference Include="CommunityToolkit.WinUI.Helpers" Version="8.1.240916" />
<PackageReference Include="CommunityToolkit.WinUI.Triggers" Version="8.1.240916" />

<!--<PackageReference Include="CommunityToolkit.WinUI.UI.Controls" Version="7.1.2" />-->
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="8.0.0" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.49-beta">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="8.0.1" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.106">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240404000" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240923002" />
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="WinUIEx" Version="2.3.4" />
<PackageReference Include="WinUIEx" Version="2.4.2" />
</ItemGroup>

<ItemGroup>
Expand Down
24 changes: 22 additions & 2 deletions PocketClient.Desktop/Services/PocketDbService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ public async Task SyncItemsAsync(bool fullSync = false, bool force = false)
try
{
lastUpdatedAt = await _localSettingsService.ReadSettingAsync<DateTimeOffset>(_pocketLastUpdatedAtKey);

// Indicates that the lastUpdatedAt setting is not set.
if (lastUpdatedAt.ToString() == "1/1/0001 12:00:00 AM")
{
lastUpdatedAt = null;
}
}
catch { }
}
Expand All @@ -119,7 +125,20 @@ public async Task SyncItemsAsync(bool fullSync = false, bool force = false)
Since = lastUpdatedAt,
};

var items = await _pocketClient.GetItemsAsync(filter, pageSize, page * pageSize);
List<PocketItem> items;

try
{
items = await _pocketClient.GetItemsAsync(filter, pageSize, page * pageSize);
}
catch (Exception ex)
{
_syncing = false;
_logger.LogError(ex, "Failed to get items from server");
WeakReferenceMessenger.Default.Send(new SyncFailureMessage("Failed to get items from server", ex));
return;
}

hasMoreItems = items.Count == pageSize;
count += items.Count;
page++;
Expand All @@ -140,7 +159,8 @@ public async Task SyncItemsAsync(bool fullSync = false, bool force = false)
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to sync item");
// In case of an error, we log the error and continue with the next item.
_logger.LogError(ex, "Failed to persist item");
}
}
} while (hasMoreItems);
Expand Down
15 changes: 14 additions & 1 deletion PocketClient.Desktop/ViewModels/ItemsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.UI.Dispatching;
using PocketClient.Core.Contracts.Services;
using PocketClient.Core.Models;
using PocketClient.Core.Specifications;
using PocketClient.Desktop.Contracts.ViewModels;
using PocketClient.Desktop.Helpers;
using PocketClient.Desktop.Models;
using Microsoft.UI.Dispatching;

namespace PocketClient.Desktop.ViewModels;

public partial class ItemsViewModel :
ObservableRecipient,
IRecipient<SyncedItemsMessage>,
IRecipient<SyncFailureMessage>,
IRecipient<ItemRemovedMessage>,
IRecipient<ItemTagsUpdatedMessage>,
INavigationAware
{
private readonly DispatcherQueue dispatcherQueue;

[ObservableProperty]
private PocketItemOrderOption orderOption;

Expand All @@ -34,6 +38,7 @@ public ItemsViewModel()
{
orderOption = PocketItemOrderOption.Newest;
filterOption = PocketItemFilterOption.All;
dispatcherQueue = DispatcherQueue.GetForCurrentThread();
}

public ObservableCollection<PocketItem> Items = new();
Expand Down Expand Up @@ -138,6 +143,14 @@ public void Receive(SyncedItemsMessage message)
});
}

public void Receive(SyncFailureMessage message)
{
dispatcherQueue.TryEnqueue(DispatcherQueuePriority.Normal, async () =>
{
await App.MainWindow.ShowMessageDialogAsync(message.Reason, "Exception_DialogTitle".Format());
});
}

public void Receive(ItemRemovedMessage message)
{
UpdateSelectedItem(message.Item);
Expand Down
13 changes: 10 additions & 3 deletions PocketClient.Desktop/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace PocketClient.Desktop.ViewModels;

public partial class SettingsViewModel : ObservableRecipient, IRecipient<SyncedItemsMessage>
public partial class SettingsViewModel : ObservableRecipient, IRecipient<SyncedItemsMessage>, IRecipient<SyncFailureMessage>
{
private readonly IThemeSelectorService _themeSelectorService;
private readonly IPocketDbService _pocketDbService;
Expand Down Expand Up @@ -76,6 +76,15 @@ public void Receive(SyncedItemsMessage message)
Syncing = false;
}

public void Receive(SyncFailureMessage message)
{
Syncing = false;
dispatcherQueue.TryEnqueue(DispatcherQueuePriority.Normal, async () =>
{
await App.MainWindow.ShowMessageDialogAsync(message.Reason, "Exception_DialogTitle".Format());
});
}

private static string GetVersion()
{
Version version;
Expand Down Expand Up @@ -145,8 +154,6 @@ private async Task SyncData()
catch (Exception ex)
{
_logger.LogError(ex, "Failed to sync data in settings page");

await App.MainWindow.ShowMessageDialogAsync(ex.Message, "Exception_DialogTitle".Format());
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion PocketClient.HttpSdk/PocketClient.HttpSdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="8.0.3" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

</Project>
8 changes: 7 additions & 1 deletion PocketClient.HttpSdk/PocketHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,13 @@ private string BuildQueryWithFilter(PocketItemFilter filter, int count, int offs

if (filter.Since != null)
{
queryParams.Add("since", $"{filter.Since?.ToUnixTimeSeconds()}");
var timestamp = filter.Since.Value.ToUnixTimeSeconds();

// The timestamp should be greater than 0.
if (timestamp > 0)
{
queryParams.Add("since", $"{timestamp}");
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions PocketClient.sln
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ Global
{0E9B135F-BC10-4524-9C00-63766F3315FA}.Debug|x64.Build.0 = Debug|x64
{0E9B135F-BC10-4524-9C00-63766F3315FA}.Debug|x86.ActiveCfg = Debug|x86
{0E9B135F-BC10-4524-9C00-63766F3315FA}.Debug|x86.Build.0 = Debug|x86
{0E9B135F-BC10-4524-9C00-63766F3315FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E9B135F-BC10-4524-9C00-63766F3315FA}.Release|Any CPU.Build.0 = Release|Any CPU
{0E9B135F-BC10-4524-9C00-63766F3315FA}.Release|Any CPU.ActiveCfg = Release|x64
{0E9B135F-BC10-4524-9C00-63766F3315FA}.Release|Any CPU.Build.0 = Release|x64
{0E9B135F-BC10-4524-9C00-63766F3315FA}.Release|arm64.ActiveCfg = Release|arm64
{0E9B135F-BC10-4524-9C00-63766F3315FA}.Release|arm64.Build.0 = Release|arm64
{0E9B135F-BC10-4524-9C00-63766F3315FA}.Release|x64.ActiveCfg = Release|x64
Expand Down Expand Up @@ -87,8 +87,8 @@ Global
{FE068BC4-6A0A-4CA8-A147-B3313D0D6998}.Debug|x64.Build.0 = Debug|x64
{FE068BC4-6A0A-4CA8-A147-B3313D0D6998}.Debug|x86.ActiveCfg = Debug|x86
{FE068BC4-6A0A-4CA8-A147-B3313D0D6998}.Debug|x86.Build.0 = Debug|x86
{FE068BC4-6A0A-4CA8-A147-B3313D0D6998}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FE068BC4-6A0A-4CA8-A147-B3313D0D6998}.Release|Any CPU.Build.0 = Release|Any CPU
{FE068BC4-6A0A-4CA8-A147-B3313D0D6998}.Release|Any CPU.ActiveCfg = Release|x64
{FE068BC4-6A0A-4CA8-A147-B3313D0D6998}.Release|Any CPU.Build.0 = Release|x64
{FE068BC4-6A0A-4CA8-A147-B3313D0D6998}.Release|arm64.ActiveCfg = Release|arm64
{FE068BC4-6A0A-4CA8-A147-B3313D0D6998}.Release|arm64.Build.0 = Release|arm64
{FE068BC4-6A0A-4CA8-A147-B3313D0D6998}.Release|x64.ActiveCfg = Release|x64
Expand Down

0 comments on commit 3f6baf4

Please sign in to comment.