16
16
using Flow . Launcher . Infrastructure . Logger ;
17
17
using System . IO ;
18
18
using Flow . Launcher . Infrastructure . UserSettings ;
19
+ using Flow . Launcher . Plugin ;
19
20
20
21
namespace Flow . Launcher . Core
21
22
{
@@ -28,11 +29,14 @@ public Updater(string gitHubRepository)
28
29
GitHubRepository = gitHubRepository ;
29
30
}
30
31
31
- public async Task UpdateApp ( bool silentIfLatestVersion = true )
32
+ public async Task UpdateApp ( IPublicAPI api , bool silentUpdate = true )
32
33
{
33
34
UpdateManager updateManager ;
34
35
UpdateInfo newUpdateInfo ;
35
36
37
+ if ( ! silentUpdate )
38
+ api . ShowMsg ( "Please wait..." , "Checking for new update" ) ;
39
+
36
40
try
37
41
{
38
42
updateManager = await GitHubUpdateManager ( GitHubRepository ) ;
@@ -62,12 +66,15 @@ public async Task UpdateApp(bool silentIfLatestVersion = true)
62
66
63
67
if ( newReleaseVersion <= currentVersion )
64
68
{
65
- if ( ! silentIfLatestVersion )
69
+ if ( ! silentUpdate )
66
70
MessageBox . Show ( "You already have the latest Flow Launcher version" ) ;
67
71
updateManager . Dispose ( ) ;
68
72
return ;
69
73
}
70
-
74
+
75
+ if ( ! silentUpdate )
76
+ api . ShowMsg ( "Update found" , "Updating..." ) ;
77
+
71
78
try
72
79
{
73
80
await updateManager . DownloadReleases ( newUpdateInfo . ReleasesToApply ) ;
@@ -96,11 +103,15 @@ public async Task UpdateApp(bool silentIfLatestVersion = true)
96
103
97
104
var newVersionTips = NewVersinoTips ( newReleaseVersion . ToString ( ) ) ;
98
105
99
- MessageBox . Show ( newVersionTips ) ;
100
106
Log . Info ( $ "|Updater.UpdateApp|Update success:{ newVersionTips } ") ;
101
107
102
108
// always dispose UpdateManager
103
109
updateManager . Dispose ( ) ;
110
+
111
+ if ( MessageBox . Show ( newVersionTips , "New Update" , MessageBoxButton . YesNo ) == MessageBoxResult . Yes )
112
+ {
113
+ UpdateManager . RestartApp ( Constant . ApplicationFileName ) ;
114
+ }
104
115
}
105
116
106
117
[ UsedImplicitly ]
0 commit comments