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.
37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
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;
|
|
}
|
|
}
|