Skip to content

Commit f636606

Browse files
committed
add update messages to indicate progress
1 parent fd56af7 commit f636606

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

Flow.Launcher.Core/Updater.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Flow.Launcher.Infrastructure.Logger;
1717
using System.IO;
1818
using Flow.Launcher.Infrastructure.UserSettings;
19+
using Flow.Launcher.Plugin;
1920

2021
namespace Flow.Launcher.Core
2122
{
@@ -28,11 +29,14 @@ public Updater(string gitHubRepository)
2829
GitHubRepository = gitHubRepository;
2930
}
3031

31-
public async Task UpdateApp(bool silentIfLatestVersion = true)
32+
public async Task UpdateApp(IPublicAPI api , bool silentUpdate = true)
3233
{
3334
UpdateManager updateManager;
3435
UpdateInfo newUpdateInfo;
3536

37+
if (!silentUpdate)
38+
api.ShowMsg("Please wait...", "Checking for new update");
39+
3640
try
3741
{
3842
updateManager = await GitHubUpdateManager(GitHubRepository);
@@ -62,12 +66,15 @@ public async Task UpdateApp(bool silentIfLatestVersion = true)
6266

6367
if (newReleaseVersion <= currentVersion)
6468
{
65-
if (!silentIfLatestVersion)
69+
if (!silentUpdate)
6670
MessageBox.Show("You already have the latest Flow Launcher version");
6771
updateManager.Dispose();
6872
return;
6973
}
70-
74+
75+
if (!silentUpdate)
76+
api.ShowMsg("Update found", "Updating...");
77+
7178
try
7279
{
7380
await updateManager.DownloadReleases(newUpdateInfo.ReleasesToApply);
@@ -96,11 +103,15 @@ public async Task UpdateApp(bool silentIfLatestVersion = true)
96103

97104
var newVersionTips = NewVersinoTips(newReleaseVersion.ToString());
98105

99-
MessageBox.Show(newVersionTips);
100106
Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}");
101107

102108
// always dispose UpdateManager
103109
updateManager.Dispose();
110+
111+
if (MessageBox.Show(newVersionTips, "New Update", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
112+
{
113+
UpdateManager.RestartApp(Constant.ApplicationFileName);
114+
}
104115
}
105116

106117
[UsedImplicitly]

Flow.Launcher/App.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ private void AutoUpdates()
118118
var timer = new Timer(1000 * 60 * 60 * 5);
119119
timer.Elapsed += async (s, e) =>
120120
{
121-
await _updater.UpdateApp();
121+
await _updater.UpdateApp(API);
122122
};
123123
timer.Start();
124124

125125
// check updates on startup
126-
await _updater.UpdateApp();
126+
await _updater.UpdateApp(API);
127127
}
128128
});
129129
}

Flow.Launcher/Languages/en.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<system:String x:Key="version">Version</system:String>
9797
<system:String x:Key="about_activate_times">You have activated Flow Launcher {0} times</system:String>
9898
<system:String x:Key="checkUpdates">Check for Updates</system:String>
99-
<system:String x:Key="newVersionTips">New version {0} is available, please restart Flow Launcher.</system:String>
99+
<system:String x:Key="newVersionTips">New version {0} is available, would you like to restart Flow Launcher to use the update?</system:String>
100100
<system:String x:Key="checkUpdatesFailed">Check updates failed, please check your connection and proxy settings to api.github.com.</system:String>
101101
<system:String x:Key="downloadUpdatesFailed">
102102
Download updates failed, please check your connection and proxy settings to github-cloud.s3.amazonaws.com,

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public SettingWindowViewModel(Updater updater, IPortable portable)
4545

4646
public async void UpdateApp()
4747
{
48-
await _updater.UpdateApp(false);
48+
await _updater.UpdateApp(App.API, false);
4949
}
5050

5151
public bool AutoUpdates

Plugins/Flow.Launcher.Plugin.Sys/Main.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,6 @@ private List<Result> Commands()
244244
{
245245
Application.Current.MainWindow.Hide();
246246
context.API.CheckForNewUpdate();
247-
context.API.ShowMsg("Please wait...",
248-
"Checking for new update");
249247
return true;
250248
}
251249
}

0 commit comments

Comments
 (0)