From 2405af88a696267b6593295c20633c8f594cf507 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Sun, 4 Jul 2021 18:35:00 +0800 Subject: [PATCH 1/4] fix unexpected Task Status --- .../PluginsManager.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs index ebb76a838d3..ac40b53bc56 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs @@ -59,11 +59,13 @@ internal Task UpdateManifest() } else { - return _downloadManifestTask = pluginsManifest.DownloadManifest().ContinueWith(t => - Context.API.ShowMsg("Plugin Manifest Download Fail.", - "Please check if you can connect to github.com. " + - "This error means you may not be able to Install and Update Plugin.", icoPath, false), + _downloadManifestTask = pluginsManifest.DownloadManifest(); + _downloadManifestTask.ContinueWith(_ => + Context.API.ShowMsg("Plugin Manifest Download Fail.", + "Please check if you can connect to github.com. " + + "This error means you may not be able to Install and Update Plugin.", icoPath, false), TaskContinuationOptions.OnlyOnFaulted); + return _downloadManifestTask; } } From 47cb7a4ebc31a4ce2f15af88fe02fa2e537d2fc1 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Sun, 4 Jul 2021 18:53:40 +0800 Subject: [PATCH 2/4] another check to avoid re-update lastUpdateTime --- Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs index f0ef89c8261..5f200aa217a 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs @@ -38,7 +38,7 @@ public Task InitAsync(PluginInitContext context) viewModel = new SettingsViewModel(context, Settings); contextMenu = new ContextMenu(Context); pluginManager = new PluginsManager(Context, Settings); - _ = pluginManager.UpdateManifest().ContinueWith(_ => + _manifestUpdateTask = pluginManager.UpdateManifest().ContinueWith(_ => { lastUpdateTime = DateTime.Now; }, TaskContinuationOptions.OnlyOnRanToCompletion); @@ -50,6 +50,8 @@ public List LoadContextMenus(Result selectedResult) { return contextMenu.LoadContextMenus(selectedResult); } + + private Task _manifestUpdateTask = Task.CompletedTask; public async Task> QueryAsync(Query query, CancellationToken token) { @@ -58,9 +60,9 @@ public async Task> QueryAsync(Query query, CancellationToken token) if (string.IsNullOrWhiteSpace(search)) return pluginManager.GetDefaultHotKeys(); - if ((DateTime.Now - lastUpdateTime).TotalHours > 12) // 12 hours + if ((DateTime.Now - lastUpdateTime).TotalHours > 12 && _manifestUpdateTask.IsCompleted) // 12 hours { - _ = pluginManager.UpdateManifest().ContinueWith(t => + _manifestUpdateTask = pluginManager.UpdateManifest().ContinueWith(t => { lastUpdateTime = DateTime.Now; }, TaskContinuationOptions.OnlyOnRanToCompletion); From 262cf90aeea8f51b0aeb05a3cb93c1201c8b9f96 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 4 Jul 2021 21:11:28 +1000 Subject: [PATCH 3/4] version bump --- Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json b/Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json index 0a28d8acd0f..a0b84ac9a30 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json @@ -6,7 +6,7 @@ "Name": "Plugins Manager", "Description": "Management of installing, uninstalling or updating Flow Launcher plugins", "Author": "Jeremy Wu", - "Version": "1.8.1", + "Version": "1.8.2", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.PluginsManager.dll", From e7b90b818e4773849736d7e227d764c37005b564 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 4 Jul 2021 21:12:22 +1000 Subject: [PATCH 4/4] add translation for download failed error msg --- .../Flow.Launcher.Plugin.PluginsManager/Languages/en.xaml | 2 ++ .../Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/en.xaml index 3017f39c3bf..c36a1dcaac2 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/en.xaml @@ -19,6 +19,8 @@ Plugin Update This plugin has an update, would you like to see it? This plugin is already installed + Plugin Manifest Download Failed + Please check if you can connect to github.com. This error means you may not be able to install or update plugins. diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs index ac40b53bc56..1aa39469b11 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs @@ -61,9 +61,8 @@ internal Task UpdateManifest() { _downloadManifestTask = pluginsManifest.DownloadManifest(); _downloadManifestTask.ContinueWith(_ => - Context.API.ShowMsg("Plugin Manifest Download Fail.", - "Please check if you can connect to github.com. " + - "This error means you may not be able to Install and Update Plugin.", icoPath, false), + Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_update_failed_title"), + Context.API.GetTranslation("plugin_pluginsmanager_update_failed_subtitle"), icoPath, false), TaskContinuationOptions.OnlyOnFaulted); return _downloadManifestTask; }