mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-04 00:26:07 +02:00
feat: Add "Check for Updates" menu item
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
</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.Extensions.Configuration.Json" Version="10.0.3" />
|
||||
<PackageReference Include="NetCoreAudio" Version="2.0.1" />
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -104,6 +104,11 @@ public sealed class MainWindow : Runnable
|
||||
/// </summary>
|
||||
public event Action<string>? OnThemeSelected;
|
||||
|
||||
/// <summary>
|
||||
/// Fired when the user requests to check for updates.
|
||||
/// </summary>
|
||||
public event Action? OnCheckForUpdatesRequested;
|
||||
|
||||
/// <summary>
|
||||
/// Fired when the user requests to view saved servers.
|
||||
/// </summary>
|
||||
@@ -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[]
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user