7
7
using Files . App . Filesystem ;
8
8
using Files . App . Filesystem . StorageItems ;
9
9
using Files . App . Helpers ;
10
+ using Files . App . ServicesImplementation ;
10
11
using Files . App . Shell ;
11
12
using Files . App . UserControls ;
12
13
using Files . App . Views ;
23
24
using System ;
24
25
using System . Collections . Generic ;
25
26
using System . Collections . ObjectModel ;
27
+ using System . ComponentModel ;
26
28
using System . IO ;
27
29
using System . Linq ;
30
+ using System . Net . Http ;
28
31
using System . Threading . Tasks ;
29
32
using System . Windows . Input ;
33
+ using Vanara . PInvoke ;
30
34
using Windows . ApplicationModel . DataTransfer ;
31
35
using Windows . Storage ;
32
36
using Windows . UI . Text ;
@@ -40,7 +44,6 @@ namespace Files.App.ViewModels
40
44
public class ToolbarViewModel : ObservableObject , IAddressToolbar , IDisposable
41
45
{
42
46
private IUserSettingsService UserSettingsService { get ; } = Ioc . Default . GetRequiredService < IUserSettingsService > ( ) ;
43
-
44
47
public IUpdateService UpdateService { get ; } = Ioc . Default . GetService < IUpdateService > ( ) ! ;
45
48
46
49
public delegate void ToolbarPathItemInvokedEventHandler ( object sender , PathNavigationEventArgs e ) ;
@@ -252,6 +255,41 @@ public bool IsLayoutAdaptive
252
255
public bool IsAdaptiveLayoutEnabled
253
256
=> UserSettingsService . FoldersSettingsService . EnableOverridingFolderPreferences ;
254
257
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
+
255
293
private bool canCopyPathInPage ;
256
294
public bool CanCopyPathInPage
257
295
{
@@ -312,13 +350,6 @@ public bool IsSearchBoxVisible
312
350
}
313
351
}
314
352
315
- private bool isReleaseNotesOpen ;
316
- public bool IsReleaseNotesOpen
317
- {
318
- get => isReleaseNotesOpen ;
319
- set => SetProperty ( ref isReleaseNotesOpen , value ) ;
320
- }
321
-
322
353
private string ? pathText ;
323
354
public string ? PathText
324
355
{
@@ -379,12 +410,33 @@ public ToolbarViewModel()
379
410
380
411
SearchBox . Escaped += SearchRegion_Escaped ;
381
412
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 ( ) ;
382
424
}
383
425
384
426
private void DoViewReleaseNotes ( )
385
427
{
386
428
IsReleaseNotesOpen = true ;
387
429
}
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
+ }
388
440
389
441
private void UserSettingsService_OnSettingChangedEvent ( object ? sender , SettingChangedEventArgs e )
390
442
{
0 commit comments