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
+6
View File
@@ -85,6 +85,7 @@ public sealed class AppOrchestrator : IDisposable
_mainWindow.OnDeleteChannelRequested += HandleDeleteChannelRequested; _mainWindow.OnDeleteChannelRequested += HandleDeleteChannelRequested;
_mainWindow.OnAudioPlayRequested += HandleAudioPlayRequested; _mainWindow.OnAudioPlayRequested += HandleAudioPlayRequested;
_mainWindow.OnFileDownloadRequested += HandleFileDownloadRequested; _mainWindow.OnFileDownloadRequested += HandleFileDownloadRequested;
_mainWindow.OnCheckForUpdatesRequested += HandleCheckForUpdatesRequested;
} }
// ── Command Handler Wiring ───────────────────────────────────────────── // ── Command Handler Wiring ─────────────────────────────────────────────
@@ -901,6 +902,11 @@ public sealed class AppOrchestrator : IDisposable
}, "Failed to download file"); }, "Failed to download file");
} }
private void HandleCheckForUpdatesRequested()
{
RunAsync(_updateService.CheckNowAsync, "Failed to check for updates");
}
// ── Private Helpers ──────────────────────────────────────────────────── // ── Private Helpers ────────────────────────────────────────────────────
private void FetchAndUpdateOnlineUsers() private void FetchAndUpdateOnlineUsers()
+1 -1
View File
@@ -5,7 +5,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AlwaysUpToDate" Version="2.0.1" /> <PackageReference Include="AlwaysUpToDate" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.3" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.3" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.3" />
<PackageReference Include="NetCoreAudio" Version="2.0.1" /> <PackageReference Include="NetCoreAudio" Version="2.0.1" />
@@ -5,6 +5,7 @@ using EchoHub.Client.UI.Dialogs;
using Serilog; using Serilog;
using Terminal.Gui.App; using Terminal.Gui.App;
using Terminal.Gui.Views;
namespace EchoHub.Client.Services; namespace EchoHub.Client.Services;
@@ -15,6 +16,8 @@ public sealed class UpdateChecker : IDisposable
private readonly Updater _updater; private readonly Updater _updater;
private readonly IApplication _app; private readonly IApplication _app;
private UpdateProgressDialog? _progressDialog; private UpdateProgressDialog? _progressDialog;
private bool _manualCheck;
public static string CurrentVersion => typeof(UpdateChecker).Assembly.GetName().Version?.ToString(3) ?? "0.0.0"; public static string CurrentVersion => typeof(UpdateChecker).Assembly.GetName().Version?.ToString(3) ?? "0.0.0";
@@ -37,6 +40,20 @@ public sealed class UpdateChecker : IDisposable
#endif #endif
} }
public async Task CheckNowAsync()
{
_manualCheck = true;
try
{
await _updater.CheckForUpdateAsync();
}
finally
{
_manualCheck = false;
}
}
private async void OnUpdateAvailable(string version, string changelogUrl) private async void OnUpdateAvailable(string version, string changelogUrl)
{ {
Log.Information("Update available: v{Version}", version); Log.Information("Update available: v{Version}", version);
@@ -83,6 +100,13 @@ public sealed class UpdateChecker : IDisposable
private void OnNoUpdateAvailable() private void OnNoUpdateAvailable()
{ {
Log.Debug("No update available"); 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) private void OnException(Exception exception)
+7 -1
View File
@@ -104,6 +104,11 @@ public sealed class MainWindow : Runnable
/// </summary> /// </summary>
public event Action<string>? OnThemeSelected; public event Action<string>? OnThemeSelected;
/// <summary>
/// Fired when the user requests to check for updates.
/// </summary>
public event Action? OnCheckForUpdatesRequested;
/// <summary> /// <summary>
/// Fired when the user requests to view saved servers. /// Fired when the user requests to view saved servers.
/// </summary> /// </summary>
@@ -322,7 +327,8 @@ public sealed class MainWindow : Runnable
[ [
new MenuBarItem("_File", 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[] new MenuBarItem("_Server", new View[]
{ {