@@ -24,7 +24,12 @@ public partial class SettingsViewModel(ILogger<SettingsViewModel> logger,
2424 private readonly UpdaterConfig _updaterConfig = updaterConfig ?? throw new ArgumentNullException ( nameof ( updaterConfig ) ) ;
2525 private readonly AppConfig _appConfig = appConfig ?? throw new ArgumentNullException ( nameof ( appConfig ) ) ;
2626 private readonly IDeploymentService _deploymentService = deploymentService ?? throw new ArgumentNullException ( nameof ( deploymentService ) ) ;
27- private bool _hasCheckedForUpdates = false ;
27+
28+ [ ObservableProperty ]
29+ private bool _isNotificationOpen ;
30+
31+ [ ObservableProperty ]
32+ private string _notificationMessage ;
2833
2934 [ ObservableProperty ]
3035 private string _versionDescription ;
@@ -89,11 +94,6 @@ private void OpenReportBug()
8994 [ RelayCommand ]
9095 private void CheckUpdates ( )
9196 {
92- if ( _hasCheckedForUpdates )
93- {
94- return ;
95- }
96-
9797 try
9898 {
9999 Uri iconUri = new Uri ( _updaterConfig . IconUri , UriKind . Absolute ) ;
@@ -114,15 +114,41 @@ private void CheckUpdates()
114114 try
115115 {
116116 var url = _deploymentService . IsRunningAsInstalled ( ) ? _updaterConfig . UpdateUrlInstaller : _updaterConfig . UpdateUrlSingle ;
117+ AutoUpdater . CheckForUpdateEvent += AutoUpdaterOnCheckForUpdateEvent ;
117118 AutoUpdater . Start ( url ) ;
118- _hasCheckedForUpdates = true ;
119119 }
120120 catch ( Exception ex )
121121 {
122122 _logger . LogError ( ex , "Check for updates failed." ) ;
123123 }
124124 }
125125
126+ private async void AutoUpdaterOnCheckForUpdateEvent ( UpdateInfoEventArgs args )
127+ {
128+ if ( args == null )
129+ {
130+ _logger . LogWarning ( "Unable to check for updates at this time." ) ;
131+ return ;
132+ }
133+
134+ if ( args . IsUpdateAvailable )
135+ {
136+ AutoUpdater . ShowUpdateForm ( args ) ;
137+ }
138+ else
139+ {
140+ await ShowNotificationAsync ( "No updates available." , TimeSpan . FromSeconds ( 3 ) ) ;
141+ }
142+ }
143+
144+ private async Task ShowNotificationAsync ( string msg , TimeSpan delay )
145+ {
146+ NotificationMessage = msg ;
147+ IsNotificationOpen = true ;
148+ await Task . Delay ( delay ) ;
149+ IsNotificationOpen = false ;
150+ }
151+
126152 partial void OnThemeChanged ( AppTheme value )
127153 {
128154 _userSettingsService . SetTheme ( value ) ;
0 commit comments