mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Workshop - Auto-updating WIP
This commit is contained in:
1 parent
99d11e1921
commit
3b2d799bfc
18 files changed
+379
-108
No files matched your search
@@ -194,7 +194,7 @@
|
||||
Auto-install updates
|
||||
</TextBlock>
|
||||
<TextBlock Classes="subtitle" TextWrapping="Wrap">
|
||||
If enabled, new updates will automatically be installed.
|
||||
Automatically install new versions of Artemis in the background when available.
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
@@ -202,6 +202,21 @@
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Border Classes="card-separator" />
|
||||
|
||||
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto" IsVisible="{CompiledBinding IsWindows}">
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock>
|
||||
Show workshop update notifications
|
||||
</TextBlock>
|
||||
<TextBlock Classes="subtitle" TextWrapping="Wrap">
|
||||
Show a desktop notification whenever workshop updates are installed.
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<ToggleSwitch IsChecked="{CompiledBinding WorkshopShowNotifications.Value}" MinWidth="0" OnContent="Yes" OffContent="No" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Border Classes="card-separator" />
|
||||
|
||||
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto">
|
||||
<StackPanel Grid.Column="0" VerticalAlignment="Center">
|
||||
|
||||
@@ -102,6 +102,7 @@ public class GeneralTabViewModel : RoutableScreen
|
||||
|
||||
public bool IsAutoRunSupported => _autoRunProvider != null;
|
||||
public bool IsWindows11 => OSVersionHelper.IsWindows11();
|
||||
public bool IsWindows => OSVersionHelper.IsWindows();
|
||||
|
||||
public ObservableCollection<LayerBrushDescriptor> LayerBrushDescriptors { get; }
|
||||
public ObservableCollection<string> GraphicsContexts { get; }
|
||||
@@ -158,6 +159,7 @@ public class GeneralTabViewModel : RoutableScreen
|
||||
public PluginSetting<bool> UIShowOnStartup => _settingsService.GetSetting("UI.ShowOnStartup", true);
|
||||
public PluginSetting<bool> EnableMica => _settingsService.GetSetting("UI.EnableMica", true);
|
||||
public PluginSetting<bool> UICheckForUpdates => _settingsService.GetSetting("UI.Updating.AutoCheck", true);
|
||||
public PluginSetting<bool> WorkshopShowNotifications => _settingsService.GetSetting("Workshop.ShowNotifications", true);
|
||||
public PluginSetting<bool> UIAutoUpdate => _settingsService.GetSetting("UI.Updating.AutoInstall", true);
|
||||
public PluginSetting<bool> ProfileEditorShowDataModelValues => _settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false);
|
||||
public PluginSetting<LogEventLevel> CoreLoggingLevel => _settingsService.GetSetting("Core.LoggingLevel", LogEventLevel.Information);
|
||||
|
||||
@@ -101,14 +101,27 @@ public partial class EntryReleaseInfoViewModel : ActivatableViewModelBase
|
||||
return;
|
||||
}
|
||||
|
||||
// If not the latest version, warn and offer to disable auto-updates
|
||||
bool disableAutoUpdates = false;
|
||||
if (Release.Id != Release.Entry.LatestReleaseId)
|
||||
{
|
||||
disableAutoUpdates = await _windowService.ShowConfirmContentDialog(
|
||||
"You are installing an older version of this entry",
|
||||
"Would you like to disable auto-updates for this entry?",
|
||||
"Yes",
|
||||
"No"
|
||||
);
|
||||
}
|
||||
|
||||
_cts = new CancellationTokenSource();
|
||||
InstallProgress = 0;
|
||||
InstallationInProgress = true;
|
||||
try
|
||||
{
|
||||
EntryInstallResult result = await _workshopService.InstallEntry(Release.Entry, Release, _progress, _cts.Token);
|
||||
if (result.IsSuccess)
|
||||
if (result.IsSuccess && result.Entry != null)
|
||||
{
|
||||
_workshopService.SetAutoUpdate(result.Entry, !disableAutoUpdates);
|
||||
_notificationService.CreateNotification().WithTitle("Installation succeeded").WithSeverity(NotificationSeverity.Success).Show();
|
||||
InstallationInProgress = false;
|
||||
await Manage();
|
||||
@@ -156,7 +169,7 @@ public partial class EntryReleaseInfoViewModel : ActivatableViewModelBase
|
||||
await UninstallPluginPrerequisites(installedEntry);
|
||||
|
||||
await _workshopService.UninstallEntry(installedEntry, CancellationToken.None);
|
||||
|
||||
|
||||
_notificationService.CreateNotification().WithTitle("Entry uninstalled").WithSeverity(NotificationSeverity.Success).Show();
|
||||
}
|
||||
finally
|
||||
|
||||
@@ -66,11 +66,9 @@
|
||||
|
||||
<!-- Info -->
|
||||
<StackPanel Grid.Column="2" Grid.Row="0" Margin="0 0 4 0" HorizontalAlignment="Right">
|
||||
<TextBlock TextAlignment="Right" Text="{CompiledBinding Entry.CreatedAt, FallbackValue=01-01-1337, Converter={StaticResource DateTimeConverter}}" />
|
||||
<TextBlock TextAlignment="Right">
|
||||
<avalonia:MaterialIcon Kind="Downloads" />
|
||||
<Run Classes="h5" Text="{CompiledBinding Entry.Downloads, FallbackValue=0}" />
|
||||
<Run>downloads</Run>
|
||||
<avalonia:MaterialIcon Kind="Harddisk" />
|
||||
<Run Text="{CompiledBinding Entry.ReleaseVersion}" />
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
|
||||
@@ -89,7 +87,7 @@
|
||||
<Button Command="{CompiledBinding ViewLocal}" HorizontalAlignment="Stretch" >Open</Button>
|
||||
<Button Command="{CompiledBinding Uninstall}" HorizontalAlignment="Stretch">Uninstall</Button>
|
||||
</StackPanel>
|
||||
<CheckBox MinHeight="26" Margin="0 4 0 0" IsEnabled="False">Auto-update</CheckBox>
|
||||
<CheckBox MinHeight="26" Margin="0 4 0 0" IsChecked="{CompiledBinding AutoUpdate}">Auto-update</CheckBox>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Library.Tabs;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
@@ -9,6 +10,7 @@ using Artemis.Core.Services;
|
||||
using Artemis.UI.DryIoc.Factories;
|
||||
using Artemis.UI.Extensions;
|
||||
using Artemis.UI.Screens.Plugins;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using Artemis.UI.Shared.Services;
|
||||
@@ -25,16 +27,19 @@ public partial class InstalledTabItemViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly IWorkshopClient _client;
|
||||
private readonly IWorkshopService _workshopService;
|
||||
private readonly IWorkshopUpdateService _workshopUpdateService;
|
||||
private readonly IRouter _router;
|
||||
private readonly IWindowService _windowService;
|
||||
private readonly IPluginManagementService _pluginManagementService;
|
||||
private readonly ISettingsVmFactory _settingsVmFactory;
|
||||
|
||||
[Notify] private bool _updateAvailable;
|
||||
[Notify] private bool _autoUpdate;
|
||||
|
||||
public InstalledTabItemViewModel(InstalledEntry entry,
|
||||
IWorkshopClient client,
|
||||
IWorkshopService workshopService,
|
||||
IWorkshopUpdateService workshopUpdateService,
|
||||
IRouter router,
|
||||
IWindowService windowService,
|
||||
IPluginManagementService pluginManagementService,
|
||||
@@ -42,10 +47,13 @@ public partial class InstalledTabItemViewModel : ActivatableViewModelBase
|
||||
{
|
||||
_client = client;
|
||||
_workshopService = workshopService;
|
||||
_workshopUpdateService = workshopUpdateService;
|
||||
_router = router;
|
||||
_windowService = windowService;
|
||||
_pluginManagementService = pluginManagementService;
|
||||
_settingsVmFactory = settingsVmFactory;
|
||||
_autoUpdate = entry.AutoUpdate;
|
||||
|
||||
Entry = entry;
|
||||
|
||||
this.WhenActivatedAsync(async _ =>
|
||||
@@ -65,6 +73,8 @@ public partial class InstalledTabItemViewModel : ActivatableViewModelBase
|
||||
UpdateAvailable = Entry.ReleaseId != Entry.LatestReleaseId;
|
||||
}
|
||||
});
|
||||
|
||||
this.WhenAnyValue(vm => vm.AutoUpdate).Skip(1).Subscribe(_ => AutoUpdateToggled());
|
||||
}
|
||||
|
||||
public InstalledEntry Entry { get; }
|
||||
@@ -108,4 +118,18 @@ public partial class InstalledTabItemViewModel : ActivatableViewModelBase
|
||||
PluginViewModel pluginViewModel = _settingsVmFactory.PluginViewModel(plugin, ReactiveCommand.Create(() => { }));
|
||||
await pluginViewModel.ExecuteRemovePrerequisites(true);
|
||||
}
|
||||
|
||||
private void AutoUpdateToggled()
|
||||
{
|
||||
_workshopService.SetAutoUpdate(Entry, AutoUpdate);
|
||||
|
||||
if (!AutoUpdate)
|
||||
return;
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await _workshopUpdateService.AutoUpdateEntry(Entry);
|
||||
UpdateAvailable = Entry.ReleaseId != Entry.LatestReleaseId;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user