mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +00:00
Added channel startup argument
This commit is contained in:
parent
0852769cc9
commit
ede29aa9f9
@ -2,7 +2,7 @@
|
||||
"profiles": {
|
||||
"Artemis.UI.Windows": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "--force-elevation --disable-forced-shutdown --pcmr"
|
||||
"commandLineArgs": "--force-elevation --disable-forced-shutdown --pcmr --channel=feature/lawn-mowing"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,37 +5,57 @@
|
||||
xmlns:settings="clr-namespace:Artemis.UI.Screens.Settings"
|
||||
xmlns:updating="clr-namespace:Artemis.UI.Screens.Settings.Updating"
|
||||
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"
|
||||
x:Class="Artemis.UI.Screens.Settings.ReleasesTabView"
|
||||
x:DataType="settings:ReleasesTabViewModel">
|
||||
<Grid ColumnDefinitions="300,*" Margin="0 10">
|
||||
<Border Classes="card-condensed" Grid.Column="0" Margin="0 0 10 0">
|
||||
<ListBox Items="{CompiledBinding ReleaseViewModels}" SelectedItem="{CompiledBinding SelectedReleaseViewModel}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="updating:ReleaseViewModel">
|
||||
<Panel>
|
||||
<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="1" Grid.Column="0" Text="{CompiledBinding CreatedAt, StringFormat={}{0:g}}" VerticalAlignment="Center" Classes="subtitle" FontSize="13" />
|
||||
<avalonia:MaterialIcon Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Grid.RowSpan="2"
|
||||
Kind="CheckCircle"
|
||||
ToolTip.Tip="Currently installed"
|
||||
Foreground="{DynamicResource SystemAccentColorLight3}"
|
||||
Width="20"
|
||||
Height="20" />
|
||||
</Grid>
|
||||
<StackPanel Margin="4" IsVisible="{CompiledBinding !IsCurrentVersion}">
|
||||
<TextBlock Text="{CompiledBinding Version}" VerticalAlignment="Center" />
|
||||
<TextBlock Text="{CompiledBinding CreatedAt, StringFormat={}{0:g}}" VerticalAlignment="Center" Classes="subtitle" FontSize="13" />
|
||||
</StackPanel>
|
||||
</Panel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Border>
|
||||
<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>
|
||||
|
||||
<ContentControl Grid.Column="1" Content="{CompiledBinding SelectedReleaseViewModel}" />
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="300,*" Margin="0 10" IsVisible="{CompiledBinding ReleaseViewModels.Count}">
|
||||
<Border Classes="card-condensed" Grid.Column="0" Margin="0 0 10 0">
|
||||
<ListBox Items="{CompiledBinding ReleaseViewModels}" SelectedItem="{CompiledBinding SelectedReleaseViewModel}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="updating:ReleaseViewModel">
|
||||
<Panel>
|
||||
<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="1" Grid.Column="0" Text="{CompiledBinding CreatedAt, StringFormat={}{0:g}}" VerticalAlignment="Center" Classes="subtitle" FontSize="13" />
|
||||
<avalonia:MaterialIcon Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Grid.RowSpan="2"
|
||||
Kind="CheckCircle"
|
||||
ToolTip.Tip="Currently installed"
|
||||
Foreground="{DynamicResource SystemAccentColorLight3}"
|
||||
Width="20"
|
||||
Height="20" />
|
||||
</Grid>
|
||||
<StackPanel Margin="4" IsVisible="{CompiledBinding !IsCurrentVersion}">
|
||||
<TextBlock Text="{CompiledBinding Version}" VerticalAlignment="Center" />
|
||||
<TextBlock Text="{CompiledBinding CreatedAt, StringFormat={}{0:g}}" VerticalAlignment="Center" Classes="subtitle" FontSize="13" />
|
||||
</StackPanel>
|
||||
</Panel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Border>
|
||||
|
||||
<ContentControl Grid.Column="1" Content="{CompiledBinding SelectedReleaseViewModel}" />
|
||||
</Grid>
|
||||
</Panel>
|
||||
</Panel>
|
||||
</UserControl>
|
||||
@ -24,6 +24,7 @@ namespace Artemis.UI.Screens.Settings;
|
||||
public class ReleasesTabViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IUpdateService _updateService;
|
||||
private readonly IUpdatingClient _updatingClient;
|
||||
private readonly INotificationService _notificationService;
|
||||
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)
|
||||
{
|
||||
_logger = logger;
|
||||
_updateService = updateService;
|
||||
_updatingClient = updatingClient;
|
||||
_notificationService = notificationService;
|
||||
|
||||
@ -47,15 +49,18 @@ public class ReleasesTabViewModel : ActivatableViewModelBase
|
||||
|
||||
DisplayName = "Releases";
|
||||
ReleaseViewModels = releaseViewModels;
|
||||
Channel = _updateService.Channel;
|
||||
this.WhenActivated(async d =>
|
||||
{
|
||||
await updateService.CacheLatestRelease();
|
||||
await _updateService.CacheLatestRelease();
|
||||
await GetMoreReleases(d.AsCancellationToken());
|
||||
SelectedReleaseViewModel = ReleaseViewModels.FirstOrDefault(r => r.ReleaseId == PreselectId) ?? ReleaseViewModels.FirstOrDefault();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public ReadOnlyObservableCollection<ReleaseViewModel> ReleaseViewModels { get; }
|
||||
public string Channel { get; }
|
||||
public string? PreselectId { get; set; }
|
||||
|
||||
public ReleaseViewModel? SelectedReleaseViewModel
|
||||
@ -79,7 +84,7 @@ public class ReleasesTabViewModel : ActivatableViewModelBase
|
||||
{
|
||||
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)
|
||||
return;
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ namespace Artemis.UI.Services.Updating;
|
||||
|
||||
public interface IUpdateService : IArtemisUIService
|
||||
{
|
||||
string Channel { get; }
|
||||
IGetNextRelease_NextPublishedRelease? CachedLatestRelease { get; }
|
||||
|
||||
Task CacheLatestRelease();
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
@ -18,15 +19,14 @@ public class UpdateService : IUpdateService
|
||||
private const double UPDATE_CHECK_INTERVAL = 3_600_000; // once per hour
|
||||
private readonly PluginSetting<bool> _autoCheck;
|
||||
private readonly PluginSetting<bool> _autoInstall;
|
||||
private readonly PluginSetting<string> _channel;
|
||||
private readonly Func<string, ReleaseInstaller> _getReleaseInstaller;
|
||||
private readonly Platform _updatePlatform;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMainWindowService _mainWindowService;
|
||||
private readonly IQueuedActionRepository _queuedActionRepository;
|
||||
private readonly Lazy<IUpdateNotificationProvider> _updateNotificationProvider;
|
||||
private readonly Platform _updatePlatform;
|
||||
private readonly IUpdatingClient _updatingClient;
|
||||
private readonly Func<string, ReleaseInstaller> _getReleaseInstaller;
|
||||
|
||||
private bool _suspendAutoCheck;
|
||||
|
||||
@ -45,6 +45,12 @@ public class UpdateService : IUpdateService
|
||||
_updateNotificationProvider = updateNotificationProvider;
|
||||
_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())
|
||||
_updatePlatform = Platform.Windows;
|
||||
else if (OperatingSystem.IsLinux())
|
||||
@ -53,8 +59,7 @@ public class UpdateService : IUpdateService
|
||||
_updatePlatform = Platform.Osx;
|
||||
else
|
||||
throw new PlatformNotSupportedException("Cannot auto update on the current platform");
|
||||
|
||||
_channel = settingsService.GetSetting("UI.Updating.Channel", "master");
|
||||
|
||||
_autoCheck = settingsService.GetSetting("UI.Updating.AutoCheck", true);
|
||||
_autoInstall = settingsService.GetSetting("UI.Updating.AutoInstall", false);
|
||||
_autoCheck.SettingChanged += HandleAutoUpdateEvent;
|
||||
@ -63,13 +68,14 @@ public class UpdateService : IUpdateService
|
||||
timer.Elapsed += HandleAutoUpdateEvent;
|
||||
timer.Start();
|
||||
|
||||
_channel.Value = "feature/gh-actions";
|
||||
_channel.Save();
|
||||
|
||||
|
||||
InstallQueuedUpdate();
|
||||
|
||||
_logger.Information("Update service initialized for {Channel} channel", Channel);
|
||||
}
|
||||
|
||||
public string Channel { get; }
|
||||
public IGetNextRelease_NextPublishedRelease? CachedLatestRelease { get; private set; }
|
||||
|
||||
private void InstallQueuedUpdate()
|
||||
{
|
||||
if (!_queuedActionRepository.IsTypeQueued("InstallUpdate"))
|
||||
@ -109,18 +115,16 @@ public class UpdateService : IUpdateService
|
||||
}
|
||||
}
|
||||
|
||||
public IGetNextRelease_NextPublishedRelease? CachedLatestRelease { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
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;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
// Update cache
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user