Replace Tyrrrz.Settings with Cogwheel

pull/1003/head
Tyrrrz 2 years ago
parent f36852a1a2
commit 404542d973

@ -13,6 +13,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Cogwheel" Version="2.0.1" />
<PackageReference Include="FuckRussia" Version="1.0.1" PrivateAssets="all" /> <PackageReference Include="FuckRussia" Version="1.0.1" PrivateAssets="all" />
<PackageReference Include="Gress" Version="2.0.1" /> <PackageReference Include="Gress" Version="2.0.1" />
<PackageReference Include="MaterialDesignColors" Version="2.1.1" /> <PackageReference Include="MaterialDesignColors" Version="2.1.1" />
@ -21,7 +22,6 @@
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" /> <PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
<PackageReference Include="Onova" Version="2.6.4" /> <PackageReference Include="Onova" Version="2.6.4" />
<PackageReference Include="Stylet" Version="1.3.6" /> <PackageReference Include="Stylet" Version="1.3.6" />
<PackageReference Include="Tyrrrz.Settings" Version="1.3.4" />
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" PrivateAssets="all" /> <PackageReference Include="PropertyChanged.Fody" Version="4.1.0" PrivateAssets="all" />
<PackageReference Include="DotnetRuntimeBootstrapper" Version="2.4.0" PrivateAssets="all" /> <PackageReference Include="DotnetRuntimeBootstrapper" Version="2.4.0" PrivateAssets="all" />
</ItemGroup> </ItemGroup>

@ -1,11 +1,12 @@
using System; using System;
using System.IO;
using Cogwheel;
using DiscordChatExporter.Core.Exporting; using DiscordChatExporter.Core.Exporting;
using Microsoft.Win32; using Microsoft.Win32;
using Tyrrrz.Settings;
namespace DiscordChatExporter.Gui.Services; namespace DiscordChatExporter.Gui.Services;
public partial class SettingsService : SettingsManager public partial class SettingsService : SettingsBase
{ {
public bool IsUkraineSupportMessageEnabled { get; set; } = true; public bool IsUkraineSupportMessageEnabled { get; set; } = true;
@ -38,13 +39,18 @@ public partial class SettingsService : SettingsManager
public string? LastAssetsDirPath { get; set; } public string? LastAssetsDirPath { get; set; }
public SettingsService() public SettingsService()
: base(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Settings.dat"))
{ {
Configuration.StorageSpace = StorageSpace.Instance;
Configuration.SubDirectoryPath = "";
Configuration.FileName = "Settings.dat";
} }
public bool ShouldSerializeLastToken() => IsTokenPersisted; public override void Save()
{
// Clear token if it's not supposed to be persisted
if (!IsTokenPersisted)
LastToken = null;
base.Save();
}
} }
public partial class SettingsService public partial class SettingsService

@ -71,10 +71,8 @@ public class DashboardViewModel : PropertyChangedBase
public void OnViewLoaded() public void OnViewLoaded()
{ {
if (_settingsService.LastToken is not null) if (!string.IsNullOrWhiteSpace(_settingsService.LastToken))
{
Token = _settingsService.LastToken; Token = _settingsService.LastToken;
}
} }
public async void ShowSettings() public async void ShowSettings()

Loading…
Cancel
Save