mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
281c18200a
11 files changed
+308
-57
No files matched your search
@@ -0,0 +1,37 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Settings.Dialogs.UpdateDialogView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<StackPanel Margin="16">
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline6TextBlock}" TextWrapping="Wrap">
|
||||
Update available
|
||||
</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignSubtitle1TextBlock}"
|
||||
Foreground="{DynamicResource MaterialDesignBodyLight}"
|
||||
Margin="0 20 0 20"
|
||||
TextWrapping="Wrap">
|
||||
A new Artemis update is available! 🥳<LineBreak/>
|
||||
You are currently running build <Run Text="{Binding CurrentBuild, Mode=OneWay}" /> while the latest build is <Run Text="{Binding LatestBuild, Mode=OneWay}" />. <LineBreak/> <LineBreak/>
|
||||
Updating Artemis will give you the latest bug(fixes), features and improvements.
|
||||
</TextBlock>
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 8 0 0">
|
||||
<Button Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Focusable="False"
|
||||
IsCancel="True"
|
||||
Command="{s:Action Cancel}"
|
||||
Content="LATER" />
|
||||
<Button x:Name="ConfirmButton"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
IsDefault="True"
|
||||
Focusable="True"
|
||||
Command="{s:Action Update}"
|
||||
Content="UPDATE" />
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Services;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings.Dialogs
|
||||
{
|
||||
public class UpdateDialogViewModel : DialogViewModelBase
|
||||
{
|
||||
private readonly JToken _buildInfo;
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly IUpdateService _updateService;
|
||||
private bool _canUpdate = true;
|
||||
|
||||
public UpdateDialogViewModel(JToken buildInfo, IUpdateService updateService, IDialogService dialogService)
|
||||
{
|
||||
_buildInfo = buildInfo;
|
||||
_updateService = updateService;
|
||||
_dialogService = dialogService;
|
||||
|
||||
CurrentBuild = Constants.BuildInfo.BuildNumberDisplay;
|
||||
LatestBuild = buildInfo?.SelectToken("value[0].buildNumber")?.Value<string>();
|
||||
}
|
||||
|
||||
public string CurrentBuild { get; }
|
||||
public string LatestBuild { get; }
|
||||
|
||||
public bool CanUpdate
|
||||
{
|
||||
get => _canUpdate;
|
||||
set => SetAndNotify(ref _canUpdate, value);
|
||||
}
|
||||
|
||||
public async Task Update()
|
||||
{
|
||||
try
|
||||
{
|
||||
CanUpdate = false;
|
||||
await _updateService.ApplyUpdate();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_dialogService.ShowExceptionDialog("An exception occurred while applying the update", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
CanUpdate = true;
|
||||
}
|
||||
|
||||
Session.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,7 +276,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.General
|
||||
return;
|
||||
|
||||
CanOfferUpdatesIfFound = false;
|
||||
bool updateFound = await _updateService.OfferUpdatesIfFound();
|
||||
bool updateFound = await _updateService.OfferUpdateIfFound();
|
||||
if (!updateFound)
|
||||
_messageService.ShowMessage("You are already running the latest Artemis build. (☞゚ヮ゚)☞");
|
||||
CanOfferUpdatesIfFound = true;
|
||||
|
||||
Reference in new issue
Block a user