diff --git a/src/App/Localization/Loc.cs b/src/App/Localization/Loc.cs index 9f42caf..c6c367b 100644 --- a/src/App/Localization/Loc.cs +++ b/src/App/Localization/Loc.cs @@ -63,6 +63,10 @@ public sealed class Loc ["help.tab.info"] = ["Info", "Info", "Info", "Info", "Info", "Info"], ["help.tab.donate"] = ["Dona", "Donate", "Donar", "Faire un don", "Doar", "Spenden"], ["help.bug.report"] = ["Segnala un bug", "Report a bug", "Informar un error", "Signaler un bug", "Reportar um bug", "Fehler melden"], + ["update.title"] = ["Aggiornamento disponibile", "Update available", "Actualización disponible", "Mise à jour disponible", "Atualização disponível", "Update verfügbar"], + ["update.message"] = ["È disponibile una nuova versione:", "A new version is available:", "Hay una nueva versión disponible:", "Une nouvelle version est disponible :", "Uma nova versão está disponível:", "Eine neue Version ist verfügbar:"], + ["update.download"] = ["Scarica", "Download", "Descargar", "Télécharger", "Baixar", "Herunterladen"], + ["update.dismiss"] = ["Ignora", "Dismiss", "Ignorar", "Ignorer", "Ignorar", "Verwerfen"], ["donate.desc"] = [ "Se questo wallet ti è utile, considera una piccola donazione allo sviluppatore.", "If you find this wallet useful, consider a small donation to the developer.", diff --git a/src/App/ViewModels/MainWindowViewModel.Update.cs b/src/App/ViewModels/MainWindowViewModel.Update.cs new file mode 100644 index 0000000..3a63ae1 --- /dev/null +++ b/src/App/ViewModels/MainWindowViewModel.Update.cs @@ -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; + + /// + /// Fire-and-forget check run once at startup. Best-effort: any failure or an + /// up-to-date app silently does nothing (see ). + /// + private async Task CheckForUpdatesAsync() + { + var latest = await UpdateChecker.CheckAsync(AppVersion); + if (latest is null) return; + + UpdateReleaseUrl = latest.HtmlUrl; + UpdateAvailableTag = latest.Tag; + IsUpdateAvailableOpen = true; + } +} diff --git a/src/App/ViewModels/MainWindowViewModel.cs b/src/App/ViewModels/MainWindowViewModel.cs index 94fff7a..fd6b655 100644 --- a/src/App/ViewModels/MainWindowViewModel.cs +++ b/src/App/ViewModels/MainWindowViewModel.cs @@ -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() diff --git a/src/App/Views/MainView.axaml b/src/App/Views/MainView.axaml index b528ac4..72f8518 100644 --- a/src/App/Views/MainView.axaml +++ b/src/App/Views/MainView.axaml @@ -1638,5 +1638,34 @@ + + + + + + + + + + + + + +