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

42 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 string _installPath;
2024-07-10 13:33:19 -04:00
public InstallerUpdateViewModel(IScreen Host, string installPath) : base(Host)
{
_installPath = installPath;
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);
2024-06-30 12:15:45 -04:00
2024-06-29 11:05:35 -04:00
if (!UpdateInfo.UpdateAvailable)
{
2024-07-10 13:33:19 -04:00
NavigateTo(new OverviewViewModel(HostScreen, _installPath));
2024-06-29 11:05:35 -04:00
}
});
}
public void NotNowCommand()
{
2024-07-10 13:33:19 -04:00
NavigateTo(new OverviewViewModel(HostScreen, _installPath));
2024-06-29 11:05:35 -04:00
}
public async Task UpdateInstallCommand()
{
await UpdateInfo.UpdateInstaller();
}
}