add installer update info to check for updates WIP
This commit is contained in:
parent
4f0eba1ac8
commit
e70e30ff57
@ -20,8 +20,6 @@ public class ReleaseCheckTask : InstallerTaskBase
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Configuration.Default.BasePath = "https://dev.sp-tarkov.com/api/v1";
|
|
||||||
|
|
||||||
var repo = new RepositoryApi(Configuration.Default);
|
var repo = new RepositoryApi(Configuration.Default);
|
||||||
|
|
||||||
SetStatus("Checking SPT Releases", "", null, ProgressStyle.Indeterminate);
|
SetStatus("Checking SPT Releases", "", null, ProgressStyle.Indeterminate);
|
||||||
|
92
SPTInstaller/Models/InstallerUpdateInfo.cs
Normal file
92
SPTInstaller/Models/InstallerUpdateInfo.cs
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
using Gitea.Api;
|
||||||
|
using Gitea.Client;
|
||||||
|
using ReactiveUI;
|
||||||
|
using Serilog;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace SPTInstaller.Models;
|
||||||
|
public class InstallerUpdateInfo : ReactiveObject
|
||||||
|
{
|
||||||
|
private bool _updateAvailable;
|
||||||
|
public bool UpdateAvailable
|
||||||
|
{
|
||||||
|
get => _updateAvailable;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _updateAvailable, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Version _currentVersion;
|
||||||
|
public Version CurrentVersion
|
||||||
|
{
|
||||||
|
get => _currentVersion;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _currentVersion, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Version _newVersion;
|
||||||
|
public Version NewVersion
|
||||||
|
{
|
||||||
|
get => _newVersion;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _newVersion, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private bool _checkingForUpdates;
|
||||||
|
public bool CheckingForUpdates
|
||||||
|
{
|
||||||
|
get => _checkingForUpdates;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _checkingForUpdates, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> CheckForUpdates()
|
||||||
|
{
|
||||||
|
CheckingForUpdates = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var repo = new RepositoryApi(Configuration.Default);
|
||||||
|
|
||||||
|
var releases = await repo.RepoListReleasesAsync("CWX", "SPT-AKI-Installer");
|
||||||
|
|
||||||
|
if (releases == null || releases.Count == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var latest = releases.FindAll(x => !x.Prerelease)[0];
|
||||||
|
|
||||||
|
if (latest == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var latestVersion = new Version(latest.TagName);
|
||||||
|
|
||||||
|
if (latestVersion == null || latestVersion <= CurrentVersion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NewVersion = latestVersion;
|
||||||
|
UpdateAvailable = true;
|
||||||
|
CheckingForUpdates = false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Logger.Error(ex, "Failed to check for updates");
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckingForUpdates = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICommand UpdateInstaller { get; set; }
|
||||||
|
|
||||||
|
public InstallerUpdateInfo(Version? currentVersion)
|
||||||
|
{
|
||||||
|
if (currentVersion == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CurrentVersion = currentVersion;
|
||||||
|
|
||||||
|
UpdateInstaller = ReactiveCommand.Create(() =>
|
||||||
|
{
|
||||||
|
// TODO: update installer here
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -9,8 +9,8 @@
|
|||||||
<PackageIcon>icon.ico</PackageIcon>
|
<PackageIcon>icon.ico</PackageIcon>
|
||||||
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
|
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
|
||||||
<Configurations>Debug;Release;TEST</Configurations>
|
<Configurations>Debug;Release;TEST</Configurations>
|
||||||
<AssemblyVersion>2.5</AssemblyVersion>
|
<AssemblyVersion>2.6</AssemblyVersion>
|
||||||
<FileVersion>2.5</FileVersion>
|
<FileVersion>2.6</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
|
using Gitea.Client;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
using SPTInstaller.Models;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SPTInstaller.ViewModels;
|
namespace SPTInstaller.ViewModels;
|
||||||
|
|
||||||
@ -19,13 +22,22 @@ public class MainWindowViewModel : ReactiveObject, IActivatableViewModel, IScree
|
|||||||
|
|
||||||
public MainWindowViewModel()
|
public MainWindowViewModel()
|
||||||
{
|
{
|
||||||
string? version = Assembly.GetExecutingAssembly().GetName()?.Version?.ToString();
|
Configuration.Default.BasePath = "https://dev.sp-tarkov.com/api/v1";
|
||||||
|
|
||||||
Title = $"SPT Installer {"v" + version ?? "--unknown version--"}";
|
Version? version = Assembly.GetExecutingAssembly().GetName()?.Version;
|
||||||
|
|
||||||
|
Title = $"SPT Installer {"v" + version?.ToString() ?? "--unknown version--"}";
|
||||||
|
|
||||||
Log.Information($"========= {Title} Started =========");
|
Log.Information($"========= {Title} Started =========");
|
||||||
Log.Information(Environment.OSVersion.VersionString);
|
Log.Information(Environment.OSVersion.VersionString);
|
||||||
|
|
||||||
|
var updateInfo = new InstallerUpdateInfo(version);
|
||||||
|
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await updateInfo.CheckForUpdates();
|
||||||
|
});
|
||||||
|
|
||||||
Router.Navigate.Execute(new PreChecksViewModel(this));
|
Router.Navigate.Execute(new PreChecksViewModel(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Window xmlns="https://github.com/avaloniaui"
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:vm="using:SPTInstaller.ViewModels"
|
xmlns:vm="using:SPTInstaller.ViewModels"
|
||||||
xmlns:rxui="using:Avalonia.ReactiveUI"
|
xmlns:rxui="using:Avalonia.ReactiveUI"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user