diff --git a/Flow.Launcher.Core/Plugin/JsonPRCModel.cs b/Flow.Launcher.Core/Plugin/JsonPRCModel.cs index b1c8ff6ea..319f760d1 100644 --- a/Flow.Launcher.Core/Plugin/JsonPRCModel.cs +++ b/Flow.Launcher.Core/Plugin/JsonPRCModel.cs @@ -51,8 +51,10 @@ namespace Flow.Launcher.Core.Plugin public class JsonRPCRequestModel : JsonRPCModelBase { + [JsonPropertyName("method")] public string Method { get; set; } + [JsonPropertyName("parameters")] public object[] Parameters { get; set; } public override string ToString() diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index 7fe771253..9183adc7b 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -21,8 +21,8 @@ namespace Flow.Launcher.Core.Plugin private static IEnumerable _contextMenuPlugins; public static List AllPlugins { get; private set; } - public static readonly List GlobalPlugins = new List(); - public static readonly Dictionary NonGlobalPlugins = new Dictionary(); + public static readonly HashSet GlobalPlugins = new(); + public static readonly Dictionary NonGlobalPlugins = new (); public static IPublicAPI API { private set; get; } @@ -118,7 +118,9 @@ namespace Flow.Launcher.Core.Plugin _contextMenuPlugins = GetPluginsForInterface(); foreach (var plugin in AllPlugins) { - foreach (var actionKeyword in plugin.Metadata.ActionKeywords) + // set distinct on each plugin's action keywords helps only firing global(*) and action keywords once where a plugin + // has multiple global and action keywords because we will only add them here once. + foreach (var actionKeyword in plugin.Metadata.ActionKeywords.Distinct()) { switch (actionKeyword) { @@ -141,7 +143,7 @@ namespace Flow.Launcher.Core.Plugin } } - public static List ValidPluginsForQuery(Query query) + public static ICollection ValidPluginsForQuery(Query query) { if (NonGlobalPlugins.ContainsKey(query.ActionKeyword)) { @@ -283,9 +285,7 @@ namespace Flow.Launcher.Core.Plugin if (oldActionkeyword == Query.GlobalPluginWildcardSign && // Plugins may have multiple ActionKeywords that are global, eg. WebSearch plugin.Metadata.ActionKeywords - .Where(x => x == Query.GlobalPluginWildcardSign) - .ToList() - .Count == 1) + .Count(x => x == Query.GlobalPluginWildcardSign) == 1) { GlobalPlugins.Remove(plugin); } diff --git a/Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs b/Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs index 29bc11480..dd768afb4 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs @@ -30,6 +30,11 @@ namespace Flow.Launcher.Infrastructure.UserSettings metadata.ActionKeywords = settings.ActionKeywords; metadata.ActionKeyword = settings.ActionKeywords[0]; } + else + { + metadata.ActionKeywords = new List(); + metadata.ActionKeyword = string.Empty; + } metadata.Disabled = settings.Disabled; metadata.Priority = settings.Priority; } diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 56ab0ff1d..abe8d681b 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -494,21 +494,16 @@ namespace Flow.Launcher.ViewModel } }, currentCancellationToken); - Task[] tasks = new Task[plugins.Count]; + // plugins is ICollection, meaning LINQ will get the Count and preallocate Array + + Task[] tasks = plugins.Select(plugin => plugin.Metadata.Disabled switch + { + false => QueryTask(plugin), + true => Task.CompletedTask + }).ToArray(); + try { - for (var i = 0; i < plugins.Count; i++) - { - if (!plugins[i].Metadata.Disabled) - { - tasks[i] = QueryTask(plugins[i]); - } - else - { - tasks[i] = Task.CompletedTask; // Avoid Null - } - } - // Check the code, WhenAll will translate all type of IEnumerable or Collection to Array, so make an array at first await Task.WhenAll(tasks); } diff --git a/Flow.Launcher/ViewModel/PluginViewModel.cs b/Flow.Launcher/ViewModel/PluginViewModel.cs index 7c8814b41..1ac320cf0 100644 --- a/Flow.Launcher/ViewModel/PluginViewModel.cs +++ b/Flow.Launcher/ViewModel/PluginViewModel.cs @@ -1,7 +1,6 @@ using System.Windows; using System.Windows.Media; using Flow.Launcher.Plugin; -using Flow.Launcher.Core.Resource; using Flow.Launcher.Infrastructure.Image; using Flow.Launcher.Core.Plugin; @@ -11,8 +10,6 @@ namespace Flow.Launcher.ViewModel { public PluginPair PluginPair { get; set; } - private readonly Internationalization _translator = InternationalizationManager.Instance; - public ImageSource Image => ImageLoader.Load(PluginPair.Metadata.IcoPath); public bool PluginState { @@ -22,7 +19,7 @@ namespace Flow.Launcher.ViewModel PluginPair.Metadata.Disabled = !value; } } - public Visibility ActionKeywordsVisibility => PluginPair.Metadata.ActionKeywords.Count > 1 ? Visibility.Collapsed : Visibility.Visible; + public Visibility ActionKeywordsVisibility => PluginPair.Metadata.ActionKeywords.Count == 1 ? Visibility.Visible : Visibility.Collapsed; public string InitilizaTime => PluginPair.Metadata.InitTime.ToString() + "ms"; public string QueryTime => PluginPair.Metadata.AvgQueryTime + "ms"; public string ActionKeywordsText => string.Join(Query.ActionKeywordSeperater, PluginPair.Metadata.ActionKeywords); diff --git a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml index ce84aa65b..e00534367 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml @@ -13,8 +13,11 @@ Reindex Indexing Index Start Menu + When enabled, Flow will load programs from the start menu Index Registry + When enabled, Flow will load programs from the registry Enable Program Description + Disabling this will also stop Flow from searching via the program desciption Suffixes Max Depth diff --git a/Plugins/Flow.Launcher.Plugin.Program/Languages/sk.xaml b/Plugins/Flow.Launcher.Plugin.Program/Languages/sk.xaml index 851233407..cb8a0f9e3 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Languages/sk.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Languages/sk.xaml @@ -12,8 +12,12 @@ Prípony súborov Reindexovať Indexovanie - Indexovať Ponuku Štart - Indexovať Registry + Indexovať ponuku Štart + Ak je povolené, Flow načíta programy z ponuky Štart + Indexovať databázu Registry + Ak je povolené, Flow načíta programy z databázy Registry + Povoliť popis programu + Zakázaním tejto funkcie sa tiež zastaví vyhľadávanie popisu programu cez Flow Prípony Max. hĺbka diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs index 89d6dcc7d..e53fb7a52 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs @@ -17,6 +17,7 @@ using Flow.Launcher.Infrastructure; using Flow.Launcher.Plugin.Program.Logger; using Rect = System.Windows.Rect; using Flow.Launcher.Plugin.SharedModels; +using Flow.Launcher.Infrastructure.Logger; namespace Flow.Launcher.Plugin.Program.Programs { @@ -81,6 +82,11 @@ namespace Flow.Launcher.Plugin.Program.Programs Apps = new List().ToArray(); } + + if (Marshal.ReleaseComObject(stream) > 0) + { + Log.Error("Flow.Launcher.Plugin.Program.Programs.UWP", "AppxManifest.xml was leaked"); + } } diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml index 45f2a609d..8712cdb83 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml @@ -16,9 +16,9 @@ - - - + + +