Added update handler.
This commit is contained in:
@@ -83,15 +83,24 @@ namespace BodyshopPartner.ViewModels
|
||||
_callingThread.ReportProgress(80);
|
||||
logger.Debug("VM Init Complete");
|
||||
Task.Run(() => Utils.HTTPServer.InitHttpServer(AddHttpStatus));
|
||||
Task.Run(() => updateCheck());
|
||||
_callingThread.ReportProgress(100);
|
||||
}
|
||||
|
||||
|
||||
private async Task updateCheck()
|
||||
{
|
||||
logger.Debug("Checking if updates are available.");
|
||||
if (await Utils.UpdateHandler.AreUpdatesAvailable())
|
||||
{
|
||||
logger.Debug("Updates are available! Installing.");
|
||||
await Utils.UpdateHandler.ApplyUpdates(Progress, Progress);
|
||||
}
|
||||
}
|
||||
|
||||
private async void _updateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
if (await Utils.UpdateHandler.AreUpdatesAvailable())
|
||||
{
|
||||
await Utils.UpdateHandler.ApplyUpdates(Progress, Progress);
|
||||
}
|
||||
await updateCheck();
|
||||
}
|
||||
|
||||
private void MonitoringPathsChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
@@ -206,7 +215,7 @@ namespace BodyshopPartner.ViewModels
|
||||
IndeterminateLoading = true;
|
||||
foreach (var s in ShopData)
|
||||
{
|
||||
if (s.Id == ActiveShop.Id) s.AssociationActive = true;
|
||||
if (s.Id == ActiveShop?.Id) s.AssociationActive = true;
|
||||
else s.AssociationActive = false;
|
||||
var r = new GraphQLRequest
|
||||
{
|
||||
@@ -228,10 +237,10 @@ namespace BodyshopPartner.ViewModels
|
||||
};
|
||||
await Utils.GraphQL.ExecuteQuery(r);
|
||||
}
|
||||
Properties.Settings.Default.LastSelectedShop = ActiveShop.Id;
|
||||
Properties.Settings.Default.LastSelectedShop = ActiveShop?.Id;
|
||||
Properties.Settings.Default.Save();
|
||||
Utils.AppMetaData.ActiveShopId = ActiveShop.Id;
|
||||
Utils.AppMetaData.ShopRegion = ActiveShop.RegionConfig;
|
||||
Utils.AppMetaData.ActiveShopId = ActiveShop?.Id;
|
||||
Utils.AppMetaData.ShopRegion = ActiveShop?.RegionConfig;
|
||||
IndeterminateLoading = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user