From 2625f6fa41c622b40e61737b24af81cfa83c2cfd Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 3 Jul 2025 10:26:12 +0800 Subject: [PATCH] Make GetPluginsForInterface private --- Flow.Launcher.Core/Plugin/PluginManager.cs | 17 ++++++++++++++++- .../Resource/Internationalization.cs | 4 ++-- Flow.Launcher/ViewModel/MainViewModel.cs | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index c79100fc5..45659aedb 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -28,6 +28,8 @@ namespace Flow.Launcher.Core.Plugin private static IEnumerable _contextMenuPlugins; private static IEnumerable _homePlugins; + private static IEnumerable _resultUpdatePlugin; + private static IEnumerable _translationPlugins; private static IEnumerable _hotkeyPlugins; public static List AllPlugins { get; private set; } @@ -257,6 +259,8 @@ namespace Flow.Launcher.Core.Plugin _contextMenuPlugins = GetPluginsForInterface(); _homePlugins = GetPluginsForInterface(); + _resultUpdatePlugin = GetPluginsForInterface(); + _translationPlugins = GetPluginsForInterface(); _hotkeyPlugins = GetPluginsForInterface(); var pluginHotkeyInfo = GetPluginHotkeyInfo(); Settings.UpdatePluginHotkeyInfo(pluginHotkeyInfo); @@ -420,7 +424,7 @@ namespace Flow.Launcher.Core.Plugin return AllPlugins.FirstOrDefault(o => o.Metadata.ID == id); } - public static IEnumerable GetPluginsForInterface() where T : IFeatures + private static IEnumerable GetPluginsForInterface() where T : IFeatures { // Handle scenario where this is called before all plugins are instantiated, e.g. language change on startup return AllPlugins?.Where(p => p.Plugin is T) ?? Array.Empty(); @@ -460,6 +464,17 @@ namespace Flow.Launcher.Core.Plugin return _homePlugins.Any(p => p.Metadata.ID == id); } + public static IList GetResultUpdatePlugin() + { + return _resultUpdatePlugin.Where(p => !PluginModified(p.Metadata.ID)).ToList(); + } + + public static IList GetTranslationPlugins() + { + // Here we still return the modified plugins to update the possible string resources + return _translationPlugins.ToList(); + } + public static Dictionary> GetPluginHotkeyInfo() { var hotkeyPluginInfos = new Dictionary>(); diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index 24edc5ed8..8879e5d63 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -74,7 +74,7 @@ namespace Flow.Launcher.Core.Resource private void AddPluginLanguageDirectories() { - foreach (var plugin in PluginManager.GetPluginsForInterface()) + foreach (var plugin in PluginManager.GetTranslationPlugins()) { var location = Assembly.GetAssembly(plugin.Plugin.GetType()).Location; var dir = Path.GetDirectoryName(location); @@ -278,7 +278,7 @@ namespace Flow.Launcher.Core.Resource private void UpdatePluginMetadataTranslations() { - foreach (var p in PluginManager.GetPluginsForInterface()) + foreach (var p in PluginManager.GetTranslationPlugins()) { if (p.Plugin is not IPluginI18n pluginI18N) return; try diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 00a2e3a97..1f5f408b3 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -260,7 +260,7 @@ namespace Flow.Launcher.ViewModel public void RegisterResultsUpdatedEvent() { - foreach (var pair in PluginManager.GetPluginsForInterface()) + foreach (var pair in PluginManager.GetResultUpdatePlugin()) { var plugin = (IResultUpdated)pair.Plugin; plugin.ResultsUpdated += (s, e) =>