Further improvements for update handling. IO-408

This commit is contained in:
Patrick Fic
2021-01-18 15:22:47 -08:00
parent 1b4e5fb3f0
commit f41488307f
9 changed files with 56 additions and 31 deletions

View File

@@ -148,7 +148,7 @@ namespace BodyshopPartner.ViewModels
async p =>
{
await InstallUpdates();
UpdateAvailable = false;
});
}
return _installUpdatesCommand;
@@ -203,7 +203,7 @@ namespace BodyshopPartner.ViewModels
p => true,
p =>
{
ToggleStartWithWindows((bool)(p));
Utils.UpdateHandler.ToggleStartWithWindows((bool)(p));
});
}
return _startWithWindowsCommand;

View File

@@ -97,12 +97,13 @@ namespace BodyshopPartner.ViewModels
}
}
private async Task InstallUpdates()
{
logger.Debug("Updates are available! Installing.");
try
{
await Utils.UpdateHandler.ApplyUpdates(UpdateProgress, UpdateProgress);
await Utils.UpdateHandler.ApplyUpdates((val) => UpdateProgress = val, (val) => UpdateProgress = val);
}
catch (Exception Ex)
@@ -198,22 +199,6 @@ namespace BodyshopPartner.ViewModels
App.Current.Shutdown();
}
public void ToggleStartWithWindows(bool shouldStart)
{
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (shouldStart)
{
// Add the value in the registry so that the application runs at startup
rkApp.SetValue(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name, System.Reflection.Assembly.GetEntryAssembly().Location);
}
else
{
// Remove the value from the registry so that the application doesn't start
rkApp.DeleteValue(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name, false);
}
}
public async Task LoadBodyshopData()
{