diff --git a/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj b/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj index 9fa9269..a0c9dd0 100644 --- a/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj +++ b/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj @@ -13,6 +13,7 @@ + @@ -21,7 +22,6 @@ - diff --git a/DiscordChatExporter.Gui/Services/SettingsService.cs b/DiscordChatExporter.Gui/Services/SettingsService.cs index 9e8d3de..07d718f 100644 --- a/DiscordChatExporter.Gui/Services/SettingsService.cs +++ b/DiscordChatExporter.Gui/Services/SettingsService.cs @@ -1,11 +1,12 @@ using System; +using System.IO; +using Cogwheel; using DiscordChatExporter.Core.Exporting; using Microsoft.Win32; -using Tyrrrz.Settings; namespace DiscordChatExporter.Gui.Services; -public partial class SettingsService : SettingsManager +public partial class SettingsService : SettingsBase { public bool IsUkraineSupportMessageEnabled { get; set; } = true; @@ -38,13 +39,18 @@ public partial class SettingsService : SettingsManager public string? LastAssetsDirPath { get; set; } 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 diff --git a/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs b/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs index ffc5b02..4044d5c 100644 --- a/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs @@ -71,10 +71,8 @@ public class DashboardViewModel : PropertyChangedBase public void OnViewLoaded() { - if (_settingsService.LastToken is not null) - { + if (!string.IsNullOrWhiteSpace(_settingsService.LastToken)) Token = _settingsService.LastToken; - } } public async void ShowSettings()