diff --git a/src/EchoHub.Client/AppOrchestrator.cs b/src/EchoHub.Client/AppOrchestrator.cs index 417a0be..b8c84a7 100644 --- a/src/EchoHub.Client/AppOrchestrator.cs +++ b/src/EchoHub.Client/AppOrchestrator.cs @@ -85,6 +85,7 @@ public sealed class AppOrchestrator : IDisposable _mainWindow.OnDeleteChannelRequested += HandleDeleteChannelRequested; _mainWindow.OnAudioPlayRequested += HandleAudioPlayRequested; _mainWindow.OnFileDownloadRequested += HandleFileDownloadRequested; + _mainWindow.OnCheckForUpdatesRequested += HandleCheckForUpdatesRequested; } // ── Command Handler Wiring ───────────────────────────────────────────── @@ -901,6 +902,11 @@ public sealed class AppOrchestrator : IDisposable }, "Failed to download file"); } + private void HandleCheckForUpdatesRequested() + { + RunAsync(_updateService.CheckNowAsync, "Failed to check for updates"); + } + // ── Private Helpers ──────────────────────────────────────────────────── private void FetchAndUpdateOnlineUsers() diff --git a/src/EchoHub.Client/EchoHub.Client.csproj b/src/EchoHub.Client/EchoHub.Client.csproj index e455ebb..70753d0 100644 --- a/src/EchoHub.Client/EchoHub.Client.csproj +++ b/src/EchoHub.Client/EchoHub.Client.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/EchoHub.Client/Services/UpdateChecker.cs b/src/EchoHub.Client/Services/UpdateChecker.cs index 5c1b37f..6f64bbb 100644 --- a/src/EchoHub.Client/Services/UpdateChecker.cs +++ b/src/EchoHub.Client/Services/UpdateChecker.cs @@ -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) diff --git a/src/EchoHub.Client/UI/MainWindow.cs b/src/EchoHub.Client/UI/MainWindow.cs index 5e0791e..de60da9 100644 --- a/src/EchoHub.Client/UI/MainWindow.cs +++ b/src/EchoHub.Client/UI/MainWindow.cs @@ -104,6 +104,11 @@ public sealed class MainWindow : Runnable /// public event Action? OnThemeSelected; + /// + /// Fired when the user requests to check for updates. + /// + public event Action? OnCheckForUpdatesRequested; + /// /// Fired when the user requests to view saved servers. /// @@ -322,7 +327,8 @@ public sealed class MainWindow : Runnable [ new MenuBarItem("_File", [ - new MenuItem("_Quit", "Quit EchoHub", () => _app.RequestStop(), Key.Empty) + new MenuItem("_Quit", "Quit EchoHub", () => _app.RequestStop(), Key.Empty), + new MenuItem($"_Check for Updates", "Check for new version", () => OnCheckForUpdatesRequested?.Invoke(), Key.Empty) ]), new MenuBarItem("_Server", new View[] {