feat(app): check GitHub releases on startup and prompt for updates
Compares the running assembly version against the latest GitHub release tag on every app launch (desktop and Android) and shows an in-app overlay with the new version tag when one is available. Best-effort: network/parse failures are silent, matching the app's existing non-blocking startup checks.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using PalladiumWallet.Core.Net;
|
||||
|
||||
namespace PalladiumWallet.App.ViewModels;
|
||||
|
||||
public partial class MainWindowViewModel
|
||||
{
|
||||
// ---- update-available overlay ----
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isUpdateAvailableOpen;
|
||||
|
||||
[ObservableProperty]
|
||||
private string updateAvailableTag = "";
|
||||
|
||||
public string UpdateReleaseUrl { get; private set; } = "";
|
||||
|
||||
[RelayCommand]
|
||||
private void CloseUpdateAvailable() => IsUpdateAvailableOpen = false;
|
||||
|
||||
/// <summary>
|
||||
/// Fire-and-forget check run once at startup. Best-effort: any failure or an
|
||||
/// up-to-date app silently does nothing (see <see cref="UpdateChecker"/>).
|
||||
/// </summary>
|
||||
private async Task CheckForUpdatesAsync()
|
||||
{
|
||||
var latest = await UpdateChecker.CheckAsync(AppVersion);
|
||||
if (latest is null) return;
|
||||
|
||||
UpdateReleaseUrl = latest.HtmlUrl;
|
||||
UpdateAvailableTag = latest.Tag;
|
||||
IsUpdateAvailableOpen = true;
|
||||
}
|
||||
}
|
||||
@@ -158,6 +158,7 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
_keepAliveTimer = new DispatcherTimer { Interval = System.TimeSpan.FromSeconds(20) };
|
||||
_keepAliveTimer.Tick += async (_, _) => await KeepAliveTickAsync();
|
||||
_keepAliveTimer.Start();
|
||||
_ = CheckForUpdatesAsync();
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task KeepAliveTickAsync()
|
||||
|
||||
Reference in New Issue
Block a user