using TeamsISO.App.Services; namespace TeamsISO.App.ViewModels; /// /// Persistent banner shown when the launch-time update check finds a newer /// release. Stays visible until the operator clicks "Get update" (which opens /// the releases page) or "Dismiss" (which hides until next launch). /// /// Distinct from because that one's tied to /// engine alerts and would force us to leak update concerns into the engine /// layer; the update banner is purely a host-shell concern. /// public sealed class UpdateBannerViewModel : ObservableObject { private bool _isVisible; private string _latestVersion = string.Empty; private string _currentVersion = string.Empty; public bool IsVisible { get => _isVisible; private set => SetField(ref _isVisible, value); } public string LatestVersion { get => _latestVersion; private set => SetField(ref _latestVersion, value); } public string CurrentVersion { get => _currentVersion; private set => SetField(ref _currentVersion, value); } /// Friendly composite "1.0.0 → 1.1.0" string for the banner. public string Message => $"Update available — v{_currentVersion} → {_latestVersion}"; public RelayCommand OpenReleasePageCommand { get; } public RelayCommand DismissCommand { get; } public UpdateBannerViewModel() { OpenReleasePageCommand = new RelayCommand(() => { UpdateChecker.OpenReleasesPage(); IsVisible = false; }); DismissCommand = new RelayCommand(() => IsVisible = false); } /// /// Show the banner with a "you're on X, latest is Y" message. Idempotent: /// re-showing while already visible just refreshes the version strings. /// public void Show(string current, string latest) { CurrentVersion = current; LatestVersion = latest; OnPropertyChanged(nameof(Message)); IsVisible = true; } }