mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-04-27 16:25:36 +00:00
Refactor using c# 12 features
This commit is contained in:
@@ -6,27 +6,20 @@ using Onova.Services;
|
||||
|
||||
namespace DiscordChatExporter.Gui.Services;
|
||||
|
||||
public class UpdateService : IDisposable
|
||||
public class UpdateService(SettingsService settingsService) : IDisposable
|
||||
{
|
||||
private readonly IUpdateManager _updateManager = new UpdateManager(
|
||||
new GithubPackageResolver("Tyrrrz", "DiscordChatExporter", "DiscordChatExporter.zip"),
|
||||
new ZipPackageExtractor()
|
||||
);
|
||||
|
||||
private readonly SettingsService _settingsService;
|
||||
|
||||
private Version? _updateVersion;
|
||||
private bool _updatePrepared;
|
||||
private bool _updaterLaunched;
|
||||
|
||||
public UpdateService(SettingsService settingsService)
|
||||
{
|
||||
_settingsService = settingsService;
|
||||
}
|
||||
|
||||
public async ValueTask<Version?> CheckForUpdatesAsync()
|
||||
{
|
||||
if (!_settingsService.IsAutoUpdateEnabled)
|
||||
if (!settingsService.IsAutoUpdateEnabled)
|
||||
return null;
|
||||
|
||||
var check = await _updateManager.CheckForUpdatesAsync();
|
||||
@@ -35,7 +28,7 @@ public class UpdateService : IDisposable
|
||||
|
||||
public async ValueTask PrepareUpdateAsync(Version version)
|
||||
{
|
||||
if (!_settingsService.IsAutoUpdateEnabled)
|
||||
if (!settingsService.IsAutoUpdateEnabled)
|
||||
return;
|
||||
|
||||
try
|
||||
@@ -55,7 +48,7 @@ public class UpdateService : IDisposable
|
||||
|
||||
public void FinalizeUpdate(bool needRestart)
|
||||
{
|
||||
if (!_settingsService.IsAutoUpdateEnabled)
|
||||
if (!settingsService.IsAutoUpdateEnabled)
|
||||
return;
|
||||
|
||||
if (_updateVersion is null || !_updatePrepared || _updaterLaunched)
|
||||
|
||||
Reference in New Issue
Block a user