Skip to content

Commit

Permalink
changed update check behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Luka Grabarevic committed Mar 16, 2017
1 parent 10717f7 commit 2b9de00
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
25 changes: 19 additions & 6 deletions BuildsAppReborn.Client/UpdateChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using BuildsAppReborn.Client.Properties;
using BuildsAppReborn.Contracts.Models;
using BuildsAppReborn.Contracts.UI.Notifications;
using log4net;
using Squirrel;

namespace BuildsAppReborn.Client
Expand Down Expand Up @@ -72,7 +73,8 @@ private async void TimerOnElapsed(Object sender, ElapsedEventArgs elapsedEventAr
private async Task UpdateCheckInternal()
{
if (!GeneralSettings.CheckForUpdates) return;
if (GeneralSettings.NotifyOnNewUpdate) this.notificationProvider.ShowMessage($"{this.version.ProductName} Update Check started", "Checking for new updates...");

this.logger.Info("Checking for update...");
try
{
var repo = Settings.Default.UpdateCheckUrl;
Expand All @@ -92,19 +94,29 @@ private async Task UpdateCheckInternal()
else
{
var result = await updateManager.UpdateApp();
if (GeneralSettings.NotifyOnNewUpdate)
if (result != null)
{
this.logger.Info("New Update found!");
if (GeneralSettings.NotifyOnNewUpdate)
{
this.notificationProvider.ShowMessage($"{this.version.ProductName} New update found!", "Update will be installed automatically on next start.");
}
}
else
{
if (result == null) this.notificationProvider.ShowMessage($"{this.version.ProductName} Update Check finished", "Currently no new updates");
else this.notificationProvider.ShowMessage($"{this.version.ProductName} New update found!", "Update will be installed automatically on next start.");
this.logger.Info("No Update found!");
}
}
}
}
}
catch (Exception exception)
{
// ToDo: add proper logging and change message text
if (GeneralSettings.NotifyOnNewUpdate) this.notificationProvider.ShowMessage($"{this.version.ProductName} Update Check failed!", "See (currently not existing) log file.");
this.logger.Error("Error while checking for update", exception);
if (GeneralSettings.NotifyOnNewUpdate)
{
this.notificationProvider.ShowMessage($"{this.version.ProductName} Update Check failed!", "See log file for more information.");
}
}
}

Expand All @@ -113,6 +125,7 @@ private async Task UpdateCheckInternal()
#region Private Fields

private readonly GlobalSettingsContainer globalSettingsContainer;
private ILog logger = LogManager.GetLogger(typeof(UpdateChecker));
private INotificationProvider notificationProvider;
private Timer timer = new Timer();
private FileVersionInfo version = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location);
Expand Down
2 changes: 1 addition & 1 deletion BuildsAppReborn.Client/Views/GeneralSettingsControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
Converter={StaticResource MinutesToTimeSpanConverter}}" />
<TextBlock Grid.Row="3"
Grid.Column="0"
Text="Notify when updating or checking" />
Text="Notify when update available" />
<CheckBox Grid.Row="3"
Grid.Column="1"
IsChecked="{Binding GeneralSettings.NotifyOnNewUpdate}"
Expand Down

0 comments on commit 2b9de00

Please sign in to comment.