77using Files . App . Filesystem ;
88using Files . App . Filesystem . StorageItems ;
99using Files . App . Helpers ;
10+ using Files . App . ServicesImplementation ;
1011using Files . App . Shell ;
1112using Files . App . UserControls ;
1213using Files . App . Views ;
2324using System ;
2425using System . Collections . Generic ;
2526using System . Collections . ObjectModel ;
27+ using System . ComponentModel ;
2628using System . IO ;
2729using System . Linq ;
30+ using System . Net . Http ;
2831using System . Threading . Tasks ;
2932using System . Windows . Input ;
33+ using Vanara . PInvoke ;
3034using Windows . ApplicationModel . DataTransfer ;
3135using Windows . Storage ;
3236using Windows . UI . Text ;
@@ -40,7 +44,6 @@ namespace Files.App.ViewModels
4044 public class ToolbarViewModel : ObservableObject , IAddressToolbar , IDisposable
4145 {
4246 private IUserSettingsService UserSettingsService { get ; } = Ioc . Default . GetRequiredService < IUserSettingsService > ( ) ;
43-
4447 public IUpdateService UpdateService { get ; } = Ioc . Default . GetService < IUpdateService > ( ) ! ;
4548
4649 public delegate void ToolbarPathItemInvokedEventHandler ( object sender , PathNavigationEventArgs e ) ;
@@ -252,6 +255,41 @@ public bool IsLayoutAdaptive
252255 public bool IsAdaptiveLayoutEnabled
253256 => UserSettingsService . FoldersSettingsService . EnableOverridingFolderPreferences ;
254257
258+ private bool isUpdating ;
259+ public bool IsUpdating
260+ {
261+ get => isUpdating ;
262+ set => SetProperty ( ref isUpdating , value ) ;
263+ }
264+
265+ private bool isUpdateAvailable ;
266+ public bool IsUpdateAvailable
267+ {
268+ get => isUpdateAvailable ;
269+ set => SetProperty ( ref isUpdateAvailable , value ) ;
270+ }
271+
272+ private string ? releaseNotes ;
273+ public string ? ReleaseNotes
274+ {
275+ get => releaseNotes ;
276+ set => SetProperty ( ref releaseNotes , value ) ;
277+ }
278+
279+ private bool isReleaseNotesVisible ;
280+ public bool IsReleaseNotesVisible
281+ {
282+ get => isReleaseNotesVisible ;
283+ set => SetProperty ( ref isReleaseNotesVisible , value ) ;
284+ }
285+
286+ private bool isReleaseNotesOpen ;
287+ public bool IsReleaseNotesOpen
288+ {
289+ get => isReleaseNotesOpen ;
290+ set => SetProperty ( ref isReleaseNotesOpen , value ) ;
291+ }
292+
255293 private bool canCopyPathInPage ;
256294 public bool CanCopyPathInPage
257295 {
@@ -312,13 +350,6 @@ public bool IsSearchBoxVisible
312350 }
313351 }
314352
315- private bool isReleaseNotesOpen ;
316- public bool IsReleaseNotesOpen
317- {
318- get => isReleaseNotesOpen ;
319- set => SetProperty ( ref isReleaseNotesOpen , value ) ;
320- }
321-
322353 private string ? pathText ;
323354 public string ? PathText
324355 {
@@ -379,12 +410,33 @@ public ToolbarViewModel()
379410
380411 SearchBox . Escaped += SearchRegion_Escaped ;
381412 UserSettingsService . OnSettingChangedEvent += UserSettingsService_OnSettingChangedEvent ;
413+ UpdateService . PropertyChanged += UpdateService_OnPropertyChanged ;
414+ }
415+
416+ private async void UpdateService_OnPropertyChanged ( object ? sender , PropertyChangedEventArgs e )
417+ {
418+ IsUpdateAvailable = UpdateService . IsUpdateAvailable ;
419+ IsUpdating = UpdateService . IsUpdating ;
420+
421+ // Bad code, result is called twice when checking for release notes
422+ if ( UpdateService . IsReleaseNotesAvailable )
423+ await CheckForReleaseNotesAsync ( ) ;
382424 }
383425
384426 private void DoViewReleaseNotes ( )
385427 {
386428 IsReleaseNotesOpen = true ;
387429 }
430+
431+ public async Task CheckForReleaseNotesAsync ( )
432+ {
433+ var result = await UpdateService . GetLatestReleaseNotesAsync ( ) ;
434+ if ( result is null )
435+ return ;
436+
437+ ReleaseNotes = result ;
438+ IsReleaseNotesVisible = true ;
439+ }
388440
389441 private void UserSettingsService_OnSettingChangedEvent ( object ? sender , SettingChangedEventArgs e )
390442 {
0 commit comments