diff --git a/DiscordChatExporter.Core/Services/ISettingsService.cs b/DiscordChatExporter.Core/Services/ISettingsService.cs index 8031a3b..7e52696 100644 --- a/DiscordChatExporter.Core/Services/ISettingsService.cs +++ b/DiscordChatExporter.Core/Services/ISettingsService.cs @@ -4,6 +4,8 @@ namespace DiscordChatExporter.Core.Services { public interface ISettingsService { + bool IsAutoUpdateEnabled { get; set; } + string DateFormat { get; set; } int MessageGroupLimit { get; set; } diff --git a/DiscordChatExporter.Core/Services/SettingsService.cs b/DiscordChatExporter.Core/Services/SettingsService.cs index 923757f..5329a59 100644 --- a/DiscordChatExporter.Core/Services/SettingsService.cs +++ b/DiscordChatExporter.Core/Services/SettingsService.cs @@ -5,6 +5,8 @@ namespace DiscordChatExporter.Core.Services { public class SettingsService : SettingsManager, ISettingsService { + public bool IsAutoUpdateEnabled { get; set; } = true; + public string DateFormat { get; set; } = "dd-MMM-yy hh:mm tt"; public int MessageGroupLimit { get; set; } = 20; diff --git a/DiscordChatExporter.Core/Services/UpdateService.cs b/DiscordChatExporter.Core/Services/UpdateService.cs index 3686afb..7a8a603 100644 --- a/DiscordChatExporter.Core/Services/UpdateService.cs +++ b/DiscordChatExporter.Core/Services/UpdateService.cs @@ -7,13 +7,16 @@ namespace DiscordChatExporter.Core.Services { public class UpdateService : IUpdateService { + private readonly ISettingsService _settingsService; private readonly UpdateManager _updateManager; private Version _lastVersion; private bool _applied; - public UpdateService() + public UpdateService(ISettingsService settingsService) { + _settingsService = settingsService; + _updateManager = new UpdateManager( new GithubPackageResolver("Tyrrrz", "DiscordChatExporter", "DiscordChatExporter.zip"), new ZipPackageExtractor()); @@ -26,6 +29,10 @@ namespace DiscordChatExporter.Core.Services return null; #endif + // Don't update if user disabled it + if (!_settingsService.IsAutoUpdateEnabled) + return null; + try { // Remove some junk left over from last update diff --git a/DiscordChatExporter.Gui/ViewModels/ISettingsViewModel.cs b/DiscordChatExporter.Gui/ViewModels/ISettingsViewModel.cs index a3929f9..aef5ba3 100644 --- a/DiscordChatExporter.Gui/ViewModels/ISettingsViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/ISettingsViewModel.cs @@ -2,6 +2,8 @@ { public interface ISettingsViewModel { + bool IsAutoUpdateEnabled { get; set; } + string DateFormat { get; set; } int MessageGroupLimit { get; set; } } diff --git a/DiscordChatExporter.Gui/ViewModels/SettingsViewModel.cs b/DiscordChatExporter.Gui/ViewModels/SettingsViewModel.cs index 09713fc..0d9cbe1 100644 --- a/DiscordChatExporter.Gui/ViewModels/SettingsViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/SettingsViewModel.cs @@ -8,6 +8,12 @@ namespace DiscordChatExporter.Gui.ViewModels { private readonly ISettingsService _settingsService; + public bool IsAutoUpdateEnabled + { + get => _settingsService.IsAutoUpdateEnabled; + set => _settingsService.IsAutoUpdateEnabled = value; + } + public string DateFormat { get => _settingsService.DateFormat; diff --git a/DiscordChatExporter.Gui/Views/SettingsDialog.ammy b/DiscordChatExporter.Gui/Views/SettingsDialog.ammy index 7561a5d..0107f7e 100644 --- a/DiscordChatExporter.Gui/Views/SettingsDialog.ammy +++ b/DiscordChatExporter.Gui/Views/SettingsDialog.ammy @@ -21,6 +21,23 @@ UserControl "DiscordChatExporter.Gui.Views.SettingsDialog" { Text: bind MessageGroupLimit } + // Auto-update + DockPanel { + LastChildFill: false + + TextBlock { + Margin: [16, 8, 16, 8] + DockPanel.Dock: Left + Text: "Auto-updates" + } + + ToggleButton { + Margin: [16, 8, 16, 8] + DockPanel.Dock: Right + IsChecked: bind IsAutoUpdateEnabled + } + } + // Save Button { Margin: 8