From 604699f8841adad24fa0dfaf386cdb86021da92d Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Sun, 4 Jul 2021 20:05:37 +0800 Subject: [PATCH 01/12] Remove Empty Entries for ProgramSuffixes.xaml.cs --- .../ProgramSuffixes.xaml.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs index d9ea3ad97..6b1f072f1 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using System; +using System.Windows; namespace Flow.Launcher.Plugin.Program { @@ -20,18 +21,21 @@ namespace Flow.Launcher.Plugin.Program private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { - if (string.IsNullOrEmpty(tbSuffixes.Text)) + var suffixes = tbSuffixes.Text.Split(Settings.SuffixSeperator, StringSplitOptions.RemoveEmptyEntries); + + if (suffixes.Length == 0) { string warning = context.API.GetTranslation("flowlauncher_plugin_program_suffixes_cannot_empty"); MessageBox.Show(warning); return; } - _settings.ProgramSuffixes = tbSuffixes.Text.Split(Settings.SuffixSeperator); + _settings.ProgramSuffixes = suffixes; + string msg = context.API.GetTranslation("flowlauncher_plugin_program_update_file_suffixes"); MessageBox.Show(msg); DialogResult = true; } } -} +} \ No newline at end of file From 2b1e0ab584c01d815280bc465388a3c522bbf412 Mon Sep 17 00:00:00 2001 From: kubalav Date: Sun, 4 Jul 2021 17:17:31 +0200 Subject: [PATCH 02/12] Update Slovak translation --- Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/sk.xaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/sk.xaml b/Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/sk.xaml index fe5afa317..52cd784ee 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/sk.xaml +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/sk.xaml @@ -19,6 +19,8 @@ Aktualizácia pluginu Tento plugin má dostupnú aktualizáciu, chcete ju zobraziť? Tento plugin je už nainštalovaný + Stiahnutie manifestu pluginu zlyhalo + Skontrolujte, či sa môžete pripojiť na github.com. Táto chyba znamená, že pravdepodobne nemôžete pluginy inštalovať alebo aktualizovať. From 38a594ca286c0b2fd894f318e8ba949bdf3df7f0 Mon Sep 17 00:00:00 2001 From: kubalav Date: Sun, 4 Jul 2021 17:19:00 +0200 Subject: [PATCH 03/12] 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 a0b84ac9a..255546686 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.2", + "Version": "1.8.3", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.PluginsManager.dll", From 4d86936a41b9587e56e1e8b56be4f998ebf2996f Mon Sep 17 00:00:00 2001 From: kubalav Date: Sun, 4 Jul 2021 17:21:47 +0200 Subject: [PATCH 04/12] add free line --- Plugins/Flow.Launcher.Plugin.WebSearch/Languages/sk.xaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/Languages/sk.xaml b/Plugins/Flow.Launcher.Plugin.WebSearch/Languages/sk.xaml index e71eaf345..90eb19cc9 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/Languages/sk.xaml +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/Languages/sk.xaml @@ -1,6 +1,7 @@  + Otvoriť vyhľadávanie v: Nové okno Nová karta From 45aa4d26fb14b765713661bd7185445acf2d0a92 Mon Sep 17 00:00:00 2001 From: kubalav Date: Sun, 4 Jul 2021 17:22:22 +0200 Subject: [PATCH 05/12] version bump --- Plugins/Flow.Launcher.Plugin.WebSearch/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/plugin.json b/Plugins/Flow.Launcher.Plugin.WebSearch/plugin.json index 679f976d3..f83b1e40b 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/plugin.json @@ -26,7 +26,7 @@ "Name": "Web Searches", "Description": "Provide the web search ability", "Author": "qianlifeng", - "Version": "1.4.0", + "Version": "1.4.1", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.WebSearch.dll", From c8d6fa058567795d936f115b6f3520fcc3dc75c0 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 5 Jul 2021 08:31:58 +1000 Subject: [PATCH 06/12] version bump for Program plugin --- Plugins/Flow.Launcher.Plugin.Program/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/plugin.json b/Plugins/Flow.Launcher.Plugin.Program/plugin.json index fe7a3415d..a37075b0c 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Program/plugin.json @@ -4,7 +4,7 @@ "Name": "Program", "Description": "Search programs in Flow.Launcher", "Author": "qianlifeng", - "Version": "1.5.3", + "Version": "1.5.4", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Program.dll", From bf91f4e892fd51e0db7cbcda5890679c57d67c80 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 5 Jul 2021 08:39:17 +1000 Subject: [PATCH 07/12] revert version bump --- Plugins/Flow.Launcher.Plugin.WebSearch/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/plugin.json b/Plugins/Flow.Launcher.Plugin.WebSearch/plugin.json index f83b1e40b..679f976d3 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/plugin.json @@ -26,7 +26,7 @@ "Name": "Web Searches", "Description": "Provide the web search ability", "Author": "qianlifeng", - "Version": "1.4.1", + "Version": "1.4.0", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.WebSearch.dll", From 908d1c412498fe5ca3fc3d67950af085a9e656bb Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Mon, 5 Jul 2021 11:03:07 +0800 Subject: [PATCH 08/12] JsonRPC camelCase and Case Insensitive --- Flow.Launcher.Core/Plugin/JsonPRCModel.cs | 19 ++++++++----------- Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs | 9 +++++---- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/JsonPRCModel.cs b/Flow.Launcher.Core/Plugin/JsonPRCModel.cs index 2b3bd61b0..5232e46da 100644 --- a/Flow.Launcher.Core/Plugin/JsonPRCModel.cs +++ b/Flow.Launcher.Core/Plugin/JsonPRCModel.cs @@ -30,12 +30,8 @@ namespace Flow.Launcher.Core.Plugin public string Data { get; set; } } - public class JsonRPCModelBase - { - public int Id { get; set; } - } - public class JsonRPCResponseModel : JsonRPCModelBase + public class JsonRPCResponseModel { public string Result { get; set; } @@ -49,18 +45,20 @@ namespace Flow.Launcher.Core.Plugin public string DebugMessage { get; set; } } - - public class JsonRPCRequestModel : JsonRPCModelBase + + public class JsonRPCRequestModel { - [JsonPropertyName("method")] public string Method { get; set; } - [JsonPropertyName("parameters")] public object[] Parameters { get; set; } + private static readonly JsonSerializerOptions options = new() + { + PropertyNamingPolicy = JsonNamingPolicy.CamelCase + }; public override string ToString() { - return JsonSerializer.Serialize(this); + return JsonSerializer.Serialize(this, options); } } @@ -77,7 +75,6 @@ namespace Flow.Launcher.Core.Plugin /// public class JsonRPCClientRequestModel : JsonRPCRequestModel { - [JsonPropertyName("dontHideAfterAction")] public bool DontHideAfterAction { get; set; } } diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs index 65f8fc608..152173749 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs @@ -47,8 +47,9 @@ namespace Flow.Launcher.Core.Plugin } } - private static readonly JsonSerializerOptions _options = new() + private static readonly JsonSerializerOptions options = new() { + PropertyNameCaseInsensitive = true, Converters = { new JsonObjectConverter() @@ -60,7 +61,7 @@ namespace Flow.Launcher.Core.Plugin if (output == Stream.Null) return null; var queryResponseModel = await - JsonSerializer.DeserializeAsync(output, _options); + JsonSerializer.DeserializeAsync(output, options); return ParseResults(queryResponseModel); } @@ -70,7 +71,7 @@ namespace Flow.Launcher.Core.Plugin if (string.IsNullOrEmpty(output)) return null; var queryResponseModel = - JsonSerializer.Deserialize(output, _options); + JsonSerializer.Deserialize(output, options); return ParseResults(queryResponseModel); } @@ -110,7 +111,7 @@ namespace Flow.Launcher.Core.Plugin return !result.JsonRPCAction.DontHideAfterAction; } - var jsonRpcRequestModel = JsonSerializer.Deserialize(actionResponse, _options); + var jsonRpcRequestModel = JsonSerializer.Deserialize(actionResponse, options); if (jsonRpcRequestModel?.Method?.StartsWith("Flow.Launcher.") ?? false) { From c7cfd2581773b2fe8a9039532eb57f31115720c6 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Mon, 5 Jul 2021 11:47:56 +0800 Subject: [PATCH 09/12] Ignore null value in deserialization to avoid unexpected nullreference issue --- Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs index 152173749..431458881 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs @@ -50,6 +50,7 @@ namespace Flow.Launcher.Core.Plugin private static readonly JsonSerializerOptions options = new() { PropertyNameCaseInsensitive = true, + IgnoreNullValues = true, Converters = { new JsonObjectConverter() @@ -63,6 +64,8 @@ namespace Flow.Launcher.Core.Plugin var queryResponseModel = await JsonSerializer.DeserializeAsync(output, options); + await output.DisposeAsync(); + return ParseResults(queryResponseModel); } From b3c64660535039dd324f9902c2828b0a52d4a2c5 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Mon, 5 Jul 2021 11:48:30 +0800 Subject: [PATCH 10/12] Check null and return input value in UserSelectedRecord.cs to avoid error thrown. --- Flow.Launcher/Storage/UserSelectedRecord.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/Storage/UserSelectedRecord.cs b/Flow.Launcher/Storage/UserSelectedRecord.cs index 8d8956cfa..23d8c4faf 100644 --- a/Flow.Launcher/Storage/UserSelectedRecord.cs +++ b/Flow.Launcher/Storage/UserSelectedRecord.cs @@ -28,6 +28,11 @@ namespace Flow.Launcher.Storage private static int GenerateStaticHashCode(string s, int start = HASH_INITIAL) { + if (s == null) + { + return start; + } + unchecked { // skip the empty space @@ -101,4 +106,4 @@ namespace Flow.Launcher.Storage return selectedCount; } } -} +} \ No newline at end of file From a18a777e75622e4c02393c3c3538c4778ba7d052 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Mon, 5 Jul 2021 16:50:50 +0800 Subject: [PATCH 11/12] Dispose Disposable or AsyncDisposable plugin on mainwindow close --- Flow.Launcher.Core/Plugin/PluginManager.cs | 16 ++++++++++++++++ Flow.Launcher/MainWindow.xaml.cs | 6 +++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index a2a009329..41a47b3d6 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -58,6 +58,22 @@ namespace Flow.Launcher.Core.Plugin API.SavePluginSettings(); } + public static async ValueTask DisposePluginsAsync() + { + foreach (var plugin in AllPlugins) + { + switch (plugin) + { + case IDisposable disposable: + disposable.Dispose(); + break; + case IAsyncDisposable asyncDisposable: + await asyncDisposable.DisposeAsync(); + break; + } + } + } + public static async Task ReloadData() { await Task.WhenAll(AllPlugins.Select(plugin => plugin.Plugin switch diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 735103938..5fab812e6 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -11,6 +11,7 @@ using Flow.Launcher.Core.Resource; using Flow.Launcher.Helper; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.ViewModel; +using Application = System.Windows.Application; using Screen = System.Windows.Forms.Screen; using ContextMenuStrip = System.Windows.Forms.ContextMenuStrip; using DataFormats = System.Windows.DataFormats; @@ -46,10 +47,13 @@ namespace Flow.Launcher InitializeComponent(); } - private void OnClosing(object sender, CancelEventArgs e) + private async void OnClosing(object sender, CancelEventArgs e) { _notifyIcon.Visible = false; _viewModel.Save(); + e.Cancel = true; + await PluginManager.DisposePluginsAsync(); + Application.Current.Shutdown(); } private void OnInitialized(object sender, EventArgs e) From e2811ce747fd50db6394cb31c33d38e147c17452 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Mon, 5 Jul 2021 16:54:19 +0800 Subject: [PATCH 12/12] dispose PluginPair.Plugin instead of PluginPair --- Flow.Launcher.Core/Plugin/PluginManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index 41a47b3d6..134c3c002 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -60,9 +60,9 @@ namespace Flow.Launcher.Core.Plugin public static async ValueTask DisposePluginsAsync() { - foreach (var plugin in AllPlugins) + foreach (var pluginPair in AllPlugins) { - switch (plugin) + switch (pluginPair.Plugin) { case IDisposable disposable: disposable.Dispose();