Skip to content

Commit 3b2ab46

Browse files
authored
Merge pull request #920 from Flow-Launcher/remove-startup-notification
Remove Startup Error notification for updating manifest and update check
2 parents 7841b6f + 7d9bd3a commit 3b2ab46

File tree

5 files changed

+55
-49
lines changed

5 files changed

+55
-49
lines changed

Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static Task UpdateManifestAsync()
3131
return UpdateTask = DownloadManifestAsync();
3232
}
3333

34-
private async static Task DownloadManifestAsync()
34+
private static async Task DownloadManifestAsync()
3535
{
3636
try
3737
{

Flow.Launcher.Core/Updater.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
9191
catch (Exception e) when (e is HttpRequestException or WebException or SocketException || e.InnerException is TimeoutException)
9292
{
9393
Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
94-
api.ShowMsg(api.GetTranslation("update_flowlauncher_fail"),
95-
api.GetTranslation("update_flowlauncher_check_connection"));
94+
if (!silentUpdate)
95+
api.ShowMsg(api.GetTranslation("update_flowlauncher_fail"),
96+
api.GetTranslation("update_flowlauncher_check_connection"));
9697
}
9798
finally
9899
{
@@ -124,7 +125,7 @@ private async Task<UpdateManager> GitHubUpdateManager(string repository)
124125
var releases = await System.Text.Json.JsonSerializer.DeserializeAsync<List<GithubRelease>>(jsonStream).ConfigureAwait(false);
125126
var latest = releases.Where(r => !r.Prerelease).OrderByDescending(r => r.PublishedAt).First();
126127
var latestUrl = latest.HtmlUrl.Replace("/tag/", "/download/");
127-
128+
128129
var client = new WebClient
129130
{
130131
Proxy = Http.WebProxy

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ public Task InitAsync(PluginInitContext context)
3838
viewModel = new SettingsViewModel(context, Settings);
3939
contextMenu = new ContextMenu(Context);
4040
pluginManager = new PluginsManager(Context, Settings);
41-
_manifestUpdateTask = pluginManager.UpdateManifestAsync().ContinueWith(_ =>
42-
{
43-
lastUpdateTime = DateTime.Now;
44-
}, TaskContinuationOptions.OnlyOnRanToCompletion);
41+
_manifestUpdateTask = pluginManager
42+
.UpdateManifestAsync(true)
43+
.ContinueWith(_ =>
44+
{
45+
lastUpdateTime = DateTime.Now;
46+
}, TaskContinuationOptions.OnlyOnRanToCompletion);
4547

4648
return Task.CompletedTask;
4749
}
@@ -50,7 +52,7 @@ public List<Result> LoadContextMenus(Result selectedResult)
5052
{
5153
return contextMenu.LoadContextMenus(selectedResult);
5254
}
53-
55+
5456
private Task _manifestUpdateTask = Task.CompletedTask;
5557

5658
public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
@@ -72,11 +74,11 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
7274
{
7375
//search could be url, no need ToLower() when passed in
7476
var s when s.StartsWith(Settings.HotKeyInstall, StringComparison.OrdinalIgnoreCase)
75-
=> await pluginManager.RequestInstallOrUpdate(search, token),
77+
=> await pluginManager.RequestInstallOrUpdate(search, token),
7678
var s when s.StartsWith(Settings.HotkeyUninstall, StringComparison.OrdinalIgnoreCase)
77-
=> pluginManager.RequestUninstall(search),
78-
var s when s.StartsWith(Settings.HotkeyUpdate, StringComparison.OrdinalIgnoreCase)
79-
=> await pluginManager.RequestUpdate(search, token),
79+
=> pluginManager.RequestUninstall(search),
80+
var s when s.StartsWith(Settings.HotkeyUpdate, StringComparison.OrdinalIgnoreCase)
81+
=> await pluginManager.RequestUpdate(search, token),
8082
_ => pluginManager.GetDefaultHotKeys().Where(hotkey =>
8183
{
8284
hotkey.Score = StringMatcher.FuzzySearch(search, hotkey.Title).Score;

Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ internal PluginsManager(PluginInitContext context, Settings settings)
5151

5252
private Task _downloadManifestTask = Task.CompletedTask;
5353

54-
internal Task UpdateManifestAsync()
54+
internal Task UpdateManifestAsync(bool silent = false)
5555
{
5656
if (_downloadManifestTask.Status == TaskStatus.Running)
5757
{
@@ -60,10 +60,11 @@ internal Task UpdateManifestAsync()
6060
else
6161
{
6262
_downloadManifestTask = PluginsManifest.UpdateTask;
63-
_downloadManifestTask.ContinueWith(_ =>
64-
Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_update_failed_title"),
65-
Context.API.GetTranslation("plugin_pluginsmanager_update_failed_subtitle"), icoPath, false),
66-
TaskContinuationOptions.OnlyOnFaulted);
63+
if (!silent)
64+
_downloadManifestTask.ContinueWith(_ =>
65+
Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_update_failed_title"),
66+
Context.API.GetTranslation("plugin_pluginsmanager_update_failed_subtitle"), icoPath, false),
67+
TaskContinuationOptions.OnlyOnFaulted);
6768
return _downloadManifestTask;
6869
}
6970
}
@@ -113,8 +114,8 @@ internal async Task InstallOrUpdate(UserPlugin plugin)
113114
.Any(x => x.Metadata.ID == plugin.ID && x.Metadata.Version.CompareTo(plugin.Version) < 0))
114115
{
115116
if (MessageBox.Show(Context.API.GetTranslation("plugin_pluginsmanager_update_exists"),
116-
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
117-
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
117+
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
118+
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
118119
Context
119120
.API
120121
.ChangeQuery(
@@ -138,13 +139,13 @@ internal async Task InstallOrUpdate(UserPlugin plugin)
138139
Environment.NewLine, Environment.NewLine);
139140

140141
if (MessageBox.Show(message, Context.API.GetTranslation("plugin_pluginsmanager_install_title"),
141-
MessageBoxButton.YesNo) == MessageBoxResult.No)
142+
MessageBoxButton.YesNo) == MessageBoxResult.No)
142143
return;
143144

144145
// at minimum should provide a name, but handle plugin that is not downloaded from plugins manifest and is a url download
145146
var downloadFilename = string.IsNullOrEmpty(plugin.Version)
146-
? $"{plugin.Name}-{Guid.NewGuid()}.zip"
147-
: $"{plugin.Name}-{plugin.Version}.zip";
147+
? $"{plugin.Name}-{Guid.NewGuid()}.zip"
148+
: $"{plugin.Name}-{plugin.Version}.zip";
148149

149150
var filePath = Path.Combine(DataLocation.PluginsDirectory, downloadFilename);
150151

@@ -161,7 +162,7 @@ internal async Task InstallOrUpdate(UserPlugin plugin)
161162
{
162163
if (e is HttpRequestException)
163164
MessageBox.Show(Context.API.GetTranslation("plugin_pluginsmanager_download_error"),
164-
Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"));
165+
Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"));
165166

166167
Context.API.ShowMsgError(Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"),
167168
string.Format(Context.API.GetTranslation("plugin_pluginsmanager_install_error_subtitle"),
@@ -173,7 +174,7 @@ internal async Task InstallOrUpdate(UserPlugin plugin)
173174
}
174175

175176
Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_install_title"),
176-
Context.API.GetTranslation("plugin_pluginsmanager_install_success_restart"));
177+
Context.API.GetTranslation("plugin_pluginsmanager_install_success_restart"));
177178

178179
Context.API.RestartApp();
179180
}
@@ -241,8 +242,8 @@ where existingPlugin.Metadata.Version.CompareTo(pluginFromManifest.Version) <
241242
Environment.NewLine, Environment.NewLine);
242243

243244
if (MessageBox.Show(message,
244-
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
245-
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
245+
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
246+
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
246247
{
247248
Uninstall(x.PluginExistingMetadata, false);
248249

@@ -277,11 +278,10 @@ await Http.DownloadAsync(x.PluginNewUserPlugin.UrlDownload, downloadToFilePath)
277278

278279
return false;
279280
},
280-
ContextData =
281+
ContextData =
281282
new UserPlugin
282283
{
283-
Website = x.PluginNewUserPlugin.Website,
284-
UrlSourceCode = x.PluginNewUserPlugin.UrlSourceCode
284+
Website = x.PluginNewUserPlugin.Website, UrlSourceCode = x.PluginNewUserPlugin.UrlSourceCode
285285
}
286286
});
287287

@@ -340,21 +340,24 @@ internal List<Result> InstallFromWeb(string url)
340340
if (Settings.WarnFromUnknownSource)
341341
{
342342
if (!InstallSourceKnown(plugin.UrlDownload)
343-
&& MessageBox.Show(string.Format(Context.API.GetTranslation("plugin_pluginsmanager_install_unknown_source_warning"),
344-
Environment.NewLine),
345-
Context.API.GetTranslation("plugin_pluginsmanager_install_unknown_source_warning_title"),
346-
MessageBoxButton.YesNo) == MessageBoxResult.No)
343+
&& MessageBox.Show(string.Format(Context.API.GetTranslation("plugin_pluginsmanager_install_unknown_source_warning"),
344+
Environment.NewLine),
345+
Context.API.GetTranslation("plugin_pluginsmanager_install_unknown_source_warning_title"),
346+
MessageBoxButton.YesNo) == MessageBoxResult.No)
347347
return false;
348348
}
349349

350350
Application.Current.MainWindow.Hide();
351351
_ = InstallOrUpdate(plugin);
352-
352+
353353
return ShouldHideWindow;
354354
}
355355
};
356356

357-
return new List<Result> { result };
357+
return new List<Result>
358+
{
359+
result
360+
};
358361
}
359362

360363
private bool InstallSourceKnown(string url)
@@ -377,7 +380,7 @@ internal async ValueTask<List<Result>> RequestInstallOrUpdate(string searchName,
377380

378381
var searchNameWithoutKeyword = searchName.Replace(Settings.HotKeyInstall, string.Empty, StringComparison.OrdinalIgnoreCase).Trim();
379382

380-
if (Uri.IsWellFormedUriString(searchNameWithoutKeyword, UriKind.Absolute)
383+
if (Uri.IsWellFormedUriString(searchNameWithoutKeyword, UriKind.Absolute)
381384
&& searchNameWithoutKeyword.Split('.').Last() == zip)
382385
return InstallFromWeb(searchNameWithoutKeyword);
383386

@@ -438,21 +441,21 @@ private void Install(UserPlugin plugin, string downloadedFilePath)
438441
if (string.IsNullOrEmpty(metadataJsonFilePath) || string.IsNullOrEmpty(pluginFolderPath))
439442
{
440443
MessageBox.Show(Context.API.GetTranslation("plugin_pluginsmanager_install_errormetadatafile"),
441-
Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"));
442-
443-
throw new FileNotFoundException (
444+
Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"));
445+
446+
throw new FileNotFoundException(
444447
string.Format("Unable to find plugin.json from the extracted zip file, or this path {0} does not exist", pluginFolderPath));
445448
}
446449

447450
if (SameOrLesserPluginVersionExists(metadataJsonFilePath))
448451
{
449452
MessageBox.Show(string.Format(Context.API.GetTranslation("plugin_pluginsmanager_install_error_duplicate"), plugin.Name),
450-
Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"));
453+
Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"));
451454

452455
throw new InvalidOperationException(
453456
string.Format("A plugin with the same ID and version already exists, " +
454-
"or the version is greater than this downloaded plugin {0}",
455-
plugin.Name));
457+
"or the version is greater than this downloaded plugin {0}",
458+
plugin.Name));
456459
}
457460

458461
var directory = string.IsNullOrEmpty(plugin.Version) ? $"{plugin.Name}-{Guid.NewGuid()}" : $"{plugin.Name}-{plugin.Version}";
@@ -491,8 +494,8 @@ internal List<Result> RequestUninstall(string search)
491494
Environment.NewLine, Environment.NewLine);
492495

493496
if (MessageBox.Show(message,
494-
Context.API.GetTranslation("plugin_pluginsmanager_uninstall_title"),
495-
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
497+
Context.API.GetTranslation("plugin_pluginsmanager_uninstall_title"),
498+
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
496499
{
497500
Application.Current.MainWindow.Hide();
498501
Uninstall(x.Metadata);
@@ -554,8 +557,8 @@ private bool SameOrLesserPluginVersionExists(string metadataPath)
554557
{
555558
var newMetadata = JsonSerializer.Deserialize<PluginMetadata>(File.ReadAllText(metadataPath));
556559
return Context.API.GetAllPlugins()
557-
.Any(x => x.Metadata.ID == newMetadata.ID
558-
&& newMetadata.Version.CompareTo(x.Metadata.Version) <= 0);
560+
.Any(x => x.Metadata.ID == newMetadata.ID
561+
&& newMetadata.Version.CompareTo(x.Metadata.Version) <= 0);
559562
}
560563
}
561-
}
564+
}

Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"Name": "Plugins Manager",
77
"Description": "Management of installing, uninstalling or updating Flow Launcher plugins",
88
"Author": "Jeremy Wu",
9-
"Version": "1.11.0",
9+
"Version": "1.11.1",
1010
"Language": "csharp",
1111
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
1212
"ExecuteFileName": "Flow.Launcher.Plugin.PluginsManager.dll",

0 commit comments

Comments
 (0)