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

Added channel startup argument

This commit is contained in:
Robert 2023-03-03 13:35:42 +01:00
parent 0852769cc9
commit ede29aa9f9
5 changed files with 75 additions and 45 deletions

View File

@ -2,7 +2,7 @@
"profiles": { "profiles": {
"Artemis.UI.Windows": { "Artemis.UI.Windows": {
"commandName": "Project", "commandName": "Project",
"commandLineArgs": "--force-elevation --disable-forced-shutdown --pcmr" "commandLineArgs": "--force-elevation --disable-forced-shutdown --pcmr --channel=feature/lawn-mowing"
} }
} }
} }

View File

@ -5,17 +5,35 @@
xmlns:settings="clr-namespace:Artemis.UI.Screens.Settings" xmlns:settings="clr-namespace:Artemis.UI.Screens.Settings"
xmlns:updating="clr-namespace:Artemis.UI.Screens.Settings.Updating" xmlns:updating="clr-namespace:Artemis.UI.Screens.Settings.Updating"
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
mc:Ignorable="d" d:DesignWidth="1000" d:DesignHeight="1400" mc:Ignorable="d" d:DesignWidth="1000" d:DesignHeight="1400"
x:Class="Artemis.UI.Screens.Settings.ReleasesTabView" x:Class="Artemis.UI.Screens.Settings.ReleasesTabView"
x:DataType="settings:ReleasesTabViewModel"> x:DataType="settings:ReleasesTabViewModel">
<Grid ColumnDefinitions="300,*" Margin="0 10"> <Panel>
<StackPanel VerticalAlignment="Center" MaxWidth="300" Spacing="15" IsVisible="{CompiledBinding Loading}">
<TextBlock TextAlignment="Center">Loading releases...</TextBlock>
<ProgressBar IsVisible="True"></ProgressBar>
</StackPanel>
<Panel IsVisible="{CompiledBinding !Loading}">
<StackPanel VerticalAlignment="Center" Spacing="15" IsVisible="{CompiledBinding !ReleaseViewModels.Count}">
<TextBlock TextAlignment="Center"
TextWrapping="Wrap"
Text="{CompiledBinding Channel, StringFormat='Found no releases for the \'{0}\' channel.'}"></TextBlock>
<controls:HyperlinkButton NavigateUri="https://wiki.artemis-rgb.com/en/channels"
HorizontalAlignment="Center">
Learn more about channels on the wiki
</controls:HyperlinkButton>
</StackPanel>
<Grid ColumnDefinitions="300,*" Margin="0 10" IsVisible="{CompiledBinding ReleaseViewModels.Count}">
<Border Classes="card-condensed" Grid.Column="0" Margin="0 0 10 0"> <Border Classes="card-condensed" Grid.Column="0" Margin="0 0 10 0">
<ListBox Items="{CompiledBinding ReleaseViewModels}" SelectedItem="{CompiledBinding SelectedReleaseViewModel}"> <ListBox Items="{CompiledBinding ReleaseViewModels}" SelectedItem="{CompiledBinding SelectedReleaseViewModel}">
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate x:DataType="updating:ReleaseViewModel"> <DataTemplate x:DataType="updating:ReleaseViewModel">
<Panel> <Panel>
<Grid Margin="4" IsVisible="{CompiledBinding IsCurrentVersion}" RowDefinitions="*,*" ColumnDefinitions="*,Auto"> <Grid Margin="4" IsVisible="{CompiledBinding IsCurrentVersion}" RowDefinitions="*,*" ColumnDefinitions="*,Auto">
<TextBlock Grid.Row="0" Grid.Column="0" Text="{CompiledBinding Version}" VerticalAlignment="Center" IsVisible="{CompiledBinding IsCurrentVersion}" FontWeight="SemiBold" /> <TextBlock Grid.Row="0" Grid.Column="0" Text="{CompiledBinding Version}" VerticalAlignment="Center" IsVisible="{CompiledBinding IsCurrentVersion}"
FontWeight="SemiBold" />
<TextBlock Grid.Row="1" Grid.Column="0" Text="{CompiledBinding CreatedAt, StringFormat={}{0:g}}" VerticalAlignment="Center" Classes="subtitle" FontSize="13" /> <TextBlock Grid.Row="1" Grid.Column="0" Text="{CompiledBinding CreatedAt, StringFormat={}{0:g}}" VerticalAlignment="Center" Classes="subtitle" FontSize="13" />
<avalonia:MaterialIcon Grid.Row="0" <avalonia:MaterialIcon Grid.Row="0"
Grid.Column="1" Grid.Column="1"
@ -38,4 +56,6 @@
<ContentControl Grid.Column="1" Content="{CompiledBinding SelectedReleaseViewModel}" /> <ContentControl Grid.Column="1" Content="{CompiledBinding SelectedReleaseViewModel}" />
</Grid> </Grid>
</Panel>
</Panel>
</UserControl> </UserControl>

View File

@ -24,6 +24,7 @@ namespace Artemis.UI.Screens.Settings;
public class ReleasesTabViewModel : ActivatableViewModelBase public class ReleasesTabViewModel : ActivatableViewModelBase
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IUpdateService _updateService;
private readonly IUpdatingClient _updatingClient; private readonly IUpdatingClient _updatingClient;
private readonly INotificationService _notificationService; private readonly INotificationService _notificationService;
private readonly SourceList<IGetReleases_PublishedReleases_Nodes> _releases; private readonly SourceList<IGetReleases_PublishedReleases_Nodes> _releases;
@ -34,6 +35,7 @@ public class ReleasesTabViewModel : ActivatableViewModelBase
public ReleasesTabViewModel(ILogger logger, IUpdateService updateService, IUpdatingClient updatingClient, IReleaseVmFactory releaseVmFactory, INotificationService notificationService) public ReleasesTabViewModel(ILogger logger, IUpdateService updateService, IUpdatingClient updatingClient, IReleaseVmFactory releaseVmFactory, INotificationService notificationService)
{ {
_logger = logger; _logger = logger;
_updateService = updateService;
_updatingClient = updatingClient; _updatingClient = updatingClient;
_notificationService = notificationService; _notificationService = notificationService;
@ -47,15 +49,18 @@ public class ReleasesTabViewModel : ActivatableViewModelBase
DisplayName = "Releases"; DisplayName = "Releases";
ReleaseViewModels = releaseViewModels; ReleaseViewModels = releaseViewModels;
Channel = _updateService.Channel;
this.WhenActivated(async d => this.WhenActivated(async d =>
{ {
await updateService.CacheLatestRelease(); await _updateService.CacheLatestRelease();
await GetMoreReleases(d.AsCancellationToken()); await GetMoreReleases(d.AsCancellationToken());
SelectedReleaseViewModel = ReleaseViewModels.FirstOrDefault(r => r.ReleaseId == PreselectId) ?? ReleaseViewModels.FirstOrDefault(); SelectedReleaseViewModel = ReleaseViewModels.FirstOrDefault(r => r.ReleaseId == PreselectId) ?? ReleaseViewModels.FirstOrDefault();
}); });
} }
public ReadOnlyObservableCollection<ReleaseViewModel> ReleaseViewModels { get; } public ReadOnlyObservableCollection<ReleaseViewModel> ReleaseViewModels { get; }
public string Channel { get; }
public string? PreselectId { get; set; } public string? PreselectId { get; set; }
public ReleaseViewModel? SelectedReleaseViewModel public ReleaseViewModel? SelectedReleaseViewModel
@ -79,7 +84,7 @@ public class ReleasesTabViewModel : ActivatableViewModelBase
{ {
Loading = true; Loading = true;
IOperationResult<IGetReleasesResult> result = await _updatingClient.GetReleases.ExecuteAsync("feature/gh-actions", Platform.Windows, 20, _lastPageInfo?.EndCursor, cancellationToken); IOperationResult<IGetReleasesResult> result = await _updatingClient.GetReleases.ExecuteAsync(_updateService.Channel, Platform.Windows, 20, _lastPageInfo?.EndCursor, cancellationToken);
if (result.Data?.PublishedReleases?.Nodes == null) if (result.Data?.PublishedReleases?.Nodes == null)
return; return;

View File

@ -6,6 +6,7 @@ namespace Artemis.UI.Services.Updating;
public interface IUpdateService : IArtemisUIService public interface IUpdateService : IArtemisUIService
{ {
string Channel { get; }
IGetNextRelease_NextPublishedRelease? CachedLatestRelease { get; } IGetNextRelease_NextPublishedRelease? CachedLatestRelease { get; }
Task CacheLatestRelease(); Task CacheLatestRelease();

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.Core; using Artemis.Core;
@ -18,15 +19,14 @@ public class UpdateService : IUpdateService
private const double UPDATE_CHECK_INTERVAL = 3_600_000; // once per hour private const double UPDATE_CHECK_INTERVAL = 3_600_000; // once per hour
private readonly PluginSetting<bool> _autoCheck; private readonly PluginSetting<bool> _autoCheck;
private readonly PluginSetting<bool> _autoInstall; private readonly PluginSetting<bool> _autoInstall;
private readonly PluginSetting<string> _channel; private readonly Platform _updatePlatform;
private readonly Func<string, ReleaseInstaller> _getReleaseInstaller;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IMainWindowService _mainWindowService; private readonly IMainWindowService _mainWindowService;
private readonly IQueuedActionRepository _queuedActionRepository; private readonly IQueuedActionRepository _queuedActionRepository;
private readonly Lazy<IUpdateNotificationProvider> _updateNotificationProvider; private readonly Lazy<IUpdateNotificationProvider> _updateNotificationProvider;
private readonly Platform _updatePlatform;
private readonly IUpdatingClient _updatingClient; private readonly IUpdatingClient _updatingClient;
private readonly Func<string, ReleaseInstaller> _getReleaseInstaller;
private bool _suspendAutoCheck; private bool _suspendAutoCheck;
@ -45,6 +45,12 @@ public class UpdateService : IUpdateService
_updateNotificationProvider = updateNotificationProvider; _updateNotificationProvider = updateNotificationProvider;
_getReleaseInstaller = getReleaseInstaller; _getReleaseInstaller = getReleaseInstaller;
string? channelArgument = Constants.StartupArguments.FirstOrDefault(a => a.StartsWith("--channel="));
if (channelArgument != null)
Channel = channelArgument.Split("=")[1];
if (string.IsNullOrWhiteSpace(Channel))
Channel = "master";
if (OperatingSystem.IsWindows()) if (OperatingSystem.IsWindows())
_updatePlatform = Platform.Windows; _updatePlatform = Platform.Windows;
else if (OperatingSystem.IsLinux()) else if (OperatingSystem.IsLinux())
@ -54,7 +60,6 @@ public class UpdateService : IUpdateService
else else
throw new PlatformNotSupportedException("Cannot auto update on the current platform"); throw new PlatformNotSupportedException("Cannot auto update on the current platform");
_channel = settingsService.GetSetting("UI.Updating.Channel", "master");
_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", false);
_autoCheck.SettingChanged += HandleAutoUpdateEvent; _autoCheck.SettingChanged += HandleAutoUpdateEvent;
@ -63,13 +68,14 @@ public class UpdateService : IUpdateService
timer.Elapsed += HandleAutoUpdateEvent; timer.Elapsed += HandleAutoUpdateEvent;
timer.Start(); timer.Start();
_channel.Value = "feature/gh-actions";
_channel.Save();
InstallQueuedUpdate(); InstallQueuedUpdate();
_logger.Information("Update service initialized for {Channel} channel", Channel);
} }
public string Channel { get; }
public IGetNextRelease_NextPublishedRelease? CachedLatestRelease { get; private set; }
private void InstallQueuedUpdate() private void InstallQueuedUpdate()
{ {
if (!_queuedActionRepository.IsTypeQueued("InstallUpdate")) if (!_queuedActionRepository.IsTypeQueued("InstallUpdate"))
@ -109,18 +115,16 @@ public class UpdateService : IUpdateService
} }
} }
public IGetNextRelease_NextPublishedRelease? CachedLatestRelease { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public async Task CacheLatestRelease() public async Task CacheLatestRelease()
{ {
IOperationResult<IGetNextReleaseResult> result = await _updatingClient.GetNextRelease.ExecuteAsync(Constants.CurrentVersion, _channel.Value, _updatePlatform); IOperationResult<IGetNextReleaseResult> result = await _updatingClient.GetNextRelease.ExecuteAsync(Constants.CurrentVersion, Channel, _updatePlatform);
CachedLatestRelease = result.Data?.NextPublishedRelease; CachedLatestRelease = result.Data?.NextPublishedRelease;
} }
public async Task<bool> CheckForUpdate() public async Task<bool> CheckForUpdate()
{ {
IOperationResult<IGetNextReleaseResult> result = await _updatingClient.GetNextRelease.ExecuteAsync(Constants.CurrentVersion, _channel.Value, _updatePlatform); IOperationResult<IGetNextReleaseResult> result = await _updatingClient.GetNextRelease.ExecuteAsync(Constants.CurrentVersion, Channel, _updatePlatform);
result.EnsureNoErrors(); result.EnsureNoErrors();
// Update cache // Update cache