SPT-AKI-Installer/SPTInstaller/ViewModels/InstallerUpdateViewModel.cs

40 lines
1.1 KiB
C#
Raw Normal View History

2024-06-29 11:05:35 -04:00
using System.Reflection;
using System.Threading.Tasks;
using ReactiveUI;
using SPTInstaller.Helpers;
using SPTInstaller.Models;
namespace SPTInstaller.ViewModels;
public class InstallerUpdateViewModel : ViewModelBase
{
2024-06-29 11:05:35 -04:00
public InstallerUpdateInfo UpdateInfo { get; set; } = new();
private InternalData _data;
private bool _debugging;
public InstallerUpdateViewModel(IScreen Host, bool debugging) : base(Host)
{
_debugging = debugging;
2024-06-29 11:05:35 -04:00
_data = ServiceHelper.Get<InternalData>() ?? throw new Exception("Failed to get internal data");
Task.Run(async () =>
{
await UpdateInfo.CheckForUpdates(Assembly.GetExecutingAssembly().GetName().Version);
if (!UpdateInfo.UpdateAvailable)
{
NavigateTo(new InstallPathSelectionViewModel(HostScreen, _debugging));
}
});
}
public void NotNowCommand()
{
NavigateTo(new InstallPathSelectionViewModel(HostScreen, _debugging));
}
public async Task UpdateInstallCommand()
{
await UpdateInfo.UpdateInstaller();
}
}