1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Fix auto installing updates, set default of auto install to true

This commit is contained in:
Robert 2023-03-26 11:40:30 +02:00
parent 4e48e4c126
commit e216737c50
3 changed files with 10 additions and 7 deletions

View File

@ -147,7 +147,7 @@ public class GeneralTabViewModel : ActivatableViewModelBase
public PluginSetting<int> UIAutoRunDelay => _settingsService.GetSetting("UI.AutoRunDelay", 15); public PluginSetting<int> UIAutoRunDelay => _settingsService.GetSetting("UI.AutoRunDelay", 15);
public PluginSetting<bool> UIShowOnStartup => _settingsService.GetSetting("UI.ShowOnStartup", true); public PluginSetting<bool> UIShowOnStartup => _settingsService.GetSetting("UI.ShowOnStartup", true);
public PluginSetting<bool> UICheckForUpdates => _settingsService.GetSetting("UI.Updating.AutoCheck", true); public PluginSetting<bool> UICheckForUpdates => _settingsService.GetSetting("UI.Updating.AutoCheck", true);
public PluginSetting<bool> UIAutoUpdate => _settingsService.GetSetting("UI.Updating.AutoInstall", false); public PluginSetting<bool> UIAutoUpdate => _settingsService.GetSetting("UI.Updating.AutoInstall", true);
public PluginSetting<bool> ProfileEditorShowDataModelValues => _settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false); public PluginSetting<bool> ProfileEditorShowDataModelValues => _settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false);
public PluginSetting<LogEventLevel> CoreLoggingLevel => _settingsService.GetSetting("Core.LoggingLevel", LogEventLevel.Information); public PluginSetting<LogEventLevel> CoreLoggingLevel => _settingsService.GetSetting("Core.LoggingLevel", LogEventLevel.Information);
public PluginSetting<string> CorePreferredGraphicsContext => _settingsService.GetSetting("Core.PreferredGraphicsContext", "Software"); public PluginSetting<string> CorePreferredGraphicsContext => _settingsService.GetSetting("Core.PreferredGraphicsContext", "Software");

View File

@ -87,7 +87,7 @@ public class StartupWizardViewModel : DialogViewModelBase<bool>
public PluginSetting<int> UIAutoRunDelay => _settingsService.GetSetting("UI.AutoRunDelay", 15); public PluginSetting<int> UIAutoRunDelay => _settingsService.GetSetting("UI.AutoRunDelay", 15);
public PluginSetting<bool> UIShowOnStartup => _settingsService.GetSetting("UI.ShowOnStartup", true); public PluginSetting<bool> UIShowOnStartup => _settingsService.GetSetting("UI.ShowOnStartup", true);
public PluginSetting<bool> UICheckForUpdates => _settingsService.GetSetting("UI.Updating.AutoCheck", true); public PluginSetting<bool> UICheckForUpdates => _settingsService.GetSetting("UI.Updating.AutoCheck", true);
public PluginSetting<bool> UIAutoUpdate => _settingsService.GetSetting("UI.Updating.AutoInstall", false); public PluginSetting<bool> UIAutoUpdate => _settingsService.GetSetting("UI.Updating.AutoInstall", true);
public int CurrentStep public int CurrentStep
{ {

View File

@ -24,6 +24,7 @@ public class UpdateService : IUpdateService
private readonly Func<Guid, ReleaseInstaller> _getReleaseInstaller; private readonly Func<Guid, ReleaseInstaller> _getReleaseInstaller;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IMainWindowService _mainWindowService;
private readonly IReleaseRepository _releaseRepository; private readonly IReleaseRepository _releaseRepository;
private readonly Lazy<IUpdateNotificationProvider> _updateNotificationProvider; private readonly Lazy<IUpdateNotificationProvider> _updateNotificationProvider;
private readonly Platform _updatePlatform; private readonly Platform _updatePlatform;
@ -40,6 +41,7 @@ public class UpdateService : IUpdateService
Func<Guid, ReleaseInstaller> getReleaseInstaller) Func<Guid, ReleaseInstaller> getReleaseInstaller)
{ {
_logger = logger; _logger = logger;
_mainWindowService = mainWindowService;
_updatingClient = updatingClient; _updatingClient = updatingClient;
_releaseRepository = releaseRepository; _releaseRepository = releaseRepository;
_updateNotificationProvider = updateNotificationProvider; _updateNotificationProvider = updateNotificationProvider;
@ -55,7 +57,7 @@ public class UpdateService : IUpdateService
throw new PlatformNotSupportedException("Cannot auto update on the current platform"); throw new PlatformNotSupportedException("Cannot auto update on the current platform");
_autoCheck = settingsService.GetSetting("UI.Updating.AutoCheck", true); _autoCheck = settingsService.GetSetting("UI.Updating.AutoCheck", true);
_autoInstall = settingsService.GetSetting("UI.Updating.AutoInstall", false); _autoInstall = settingsService.GetSetting("UI.Updating.AutoInstall", true);
_autoCheck.SettingChanged += HandleAutoUpdateEvent; _autoCheck.SettingChanged += HandleAutoUpdateEvent;
mainWindowService.MainWindowOpened += HandleAutoUpdateEvent; mainWindowService.MainWindowOpened += HandleAutoUpdateEvent;
Timer timer = new(UPDATE_CHECK_INTERVAL); Timer timer = new(UPDATE_CHECK_INTERVAL);
@ -102,7 +104,7 @@ public class UpdateService : IUpdateService
{ {
ReleaseInstaller installer = _getReleaseInstaller(release.Id); ReleaseInstaller installer = _getReleaseInstaller(release.Id);
await installer.InstallAsync(CancellationToken.None); await installer.InstallAsync(CancellationToken.None);
Utilities.ApplyUpdate(true); RestartForUpdate(true);
} }
private async void HandleAutoUpdateEvent(object? sender, EventArgs e) private async void HandleAutoUpdateEvent(object? sender, EventArgs e)
@ -156,11 +158,12 @@ public class UpdateService : IUpdateService
if (CachedLatestRelease == null) if (CachedLatestRelease == null)
return false; return false;
// Only offer it once per session // Unless auto install is enabled, only offer it once per session
if (!_autoInstall.Value)
_suspendAutoCheck = true; _suspendAutoCheck = true;
// If the window is open show the changelog, don't auto-update while the user is busy // If the window is open show the changelog, don't auto-update while the user is busy
if (!_autoInstall.Value) if (_mainWindowService.IsMainWindowOpen || !_autoInstall.Value)
ShowUpdateNotification(CachedLatestRelease); ShowUpdateNotification(CachedLatestRelease);
else else
await AutoInstallUpdate(CachedLatestRelease); await AutoInstallUpdate(CachedLatestRelease);