2 Commits

Author SHA1 Message Date
adab62394b Tweak updating 2024-09-26 20:44:25 -04:00
da388bf953 Test new version 2024-09-26 20:36:31 -04:00

View File

@@ -22,6 +22,8 @@ internal class WindowSource : IWindowSource, IDisposable
private readonly Timer _timer;
private readonly Dispatcher _dispatcher;
private readonly UpdateManager _updateManager;
private List<TimeZoneEntry> _timeZoneEntries;
internal WindowSource()
@@ -31,6 +33,8 @@ internal class WindowSource : IWindowSource, IDisposable
_dispatcher = Dispatcher.CurrentDispatcher;
_updateManager = new UpdateManager(new GithubSource("https://github.com/ckaczor/WorldClockStatusWindow", null, false));
_timer = new Timer(1000);
Task.Factory.StartNew(UpdateApp).ContinueWith(_ => Start());
@@ -40,25 +44,23 @@ internal class WindowSource : IWindowSource, IDisposable
{
try
{
var updateManager = new UpdateManager(new GithubSource("https://github.com/ckaczor/WorldClockStatusWindow", null, false));
if (!updateManager.IsInstalled)
if (!_updateManager.IsInstalled)
return false;
_dispatcher.Invoke(() => _floatingStatusWindow.SetText("Checking for update..."));
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText("Checking for update..."));
var newVersion = await updateManager.CheckForUpdatesAsync();
var newVersion = await _updateManager.CheckForUpdatesAsync();
if (newVersion == null)
return false;
_dispatcher.Invoke(() => _floatingStatusWindow.SetText("Downloading update..."));
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText("Downloading update..."));
await updateManager.DownloadUpdatesAsync(newVersion);
await _updateManager.DownloadUpdatesAsync(newVersion);
_dispatcher.Invoke(() => _floatingStatusWindow.SetText("Installing update..."));
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText("Installing update..."));
updateManager.ApplyUpdatesAndRestart(newVersion);
_updateManager.ApplyUpdatesAndRestart(newVersion);
}
catch (Exception e)
{
@@ -117,7 +119,7 @@ internal class WindowSource : IWindowSource, IDisposable
text.AppendLine();
text.AppendLine();
text.Append($"Version: {Assembly.GetEntryAssembly()!.GetName().Version!.ToString()}");
text.Append(_updateManager.CurrentVersion);
_dispatcher.Invoke(() => _floatingStatusWindow.SetText(text.ToString()));
}