feat: Add "Check for Updates" menu item

This commit is contained in:
Stone_Red
2026-02-23 17:20:38 +01:00
parent 81b09b1af7
commit 0e3dd932af
4 changed files with 38 additions and 2 deletions
@@ -5,6 +5,7 @@ using EchoHub.Client.UI.Dialogs;
using Serilog;
using Terminal.Gui.App;
using Terminal.Gui.Views;
namespace EchoHub.Client.Services;
@@ -15,6 +16,8 @@ public sealed class UpdateChecker : IDisposable
private readonly Updater _updater;
private readonly IApplication _app;
private UpdateProgressDialog? _progressDialog;
private bool _manualCheck;
public static string CurrentVersion => typeof(UpdateChecker).Assembly.GetName().Version?.ToString(3) ?? "0.0.0";
@@ -37,6 +40,20 @@ public sealed class UpdateChecker : IDisposable
#endif
}
public async Task CheckNowAsync()
{
_manualCheck = true;
try
{
await _updater.CheckForUpdateAsync();
}
finally
{
_manualCheck = false;
}
}
private async void OnUpdateAvailable(string version, string changelogUrl)
{
Log.Information("Update available: v{Version}", version);
@@ -83,6 +100,13 @@ public sealed class UpdateChecker : IDisposable
private void OnNoUpdateAvailable()
{
Log.Debug("No update available");
if (_manualCheck)
{
_app.Invoke(() =>
{
MessageBox.Query(_app, "Check for Updates", $"You are already on the latest version (v{CurrentVersion}).", "OK");
});
}
}
private void OnException(Exception exception)