From 297cb5c3efc1b7d09d60719713c4348db0e7fd5a Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 2 Oct 2025 22:23:07 +0800 Subject: [PATCH] Return results to tell users that this plugin is still initializing --- Flow.Launcher.Core/Plugin/PluginManager.cs | 55 ++++++++++++++++++++++ Flow.Launcher/Languages/en.xaml | 2 + 2 files changed, 57 insertions(+) diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index 71234eb18..e76306f58 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -383,6 +383,28 @@ namespace Flow.Launcher.Core.Plugin var results = new List(); var metadata = pair.Metadata; + if (IsPluginInitializing(metadata)) + { + Result r = new() + { + Title = Localize.pluginStillInitializing(metadata.Name), + SubTitle = Localize.pluginStillInitializingSubtitle(), + IcoPath = metadata.IcoPath, + PluginDirectory = metadata.PluginDirectory, + ActionKeywordAssigned = query.ActionKeyword, + PluginID = metadata.ID, + OriginQuery = query, + Action = _ => + { + PublicApi.Instance.ReQuery(); + return false; + }, + Score = -100 + }; + results.Add(r); + return results; + } + try { var milliseconds = await PublicApi.Instance.StopwatchLogDebugAsync(ClassName, $"Cost for {metadata.Name}", @@ -427,6 +449,28 @@ namespace Flow.Launcher.Core.Plugin var results = new List(); var metadata = pair.Metadata; + if (IsPluginInitializing(metadata)) + { + Result r = new() + { + Title = Localize.pluginStillInitializing(metadata.Name), + SubTitle = Localize.pluginStillInitializingSubtitle(), + IcoPath = metadata.IcoPath, + PluginDirectory = metadata.PluginDirectory, + ActionKeywordAssigned = query.ActionKeyword, + PluginID = metadata.ID, + OriginQuery = query, + Action = _ => + { + PublicApi.Instance.ReQuery(); + return false; + }, + Score = -100 + }; + results.Add(r); + return results; + } + try { var milliseconds = await PublicApi.Instance.StopwatchLogDebugAsync(ClassName, $"Cost for {metadata.Name}", @@ -457,6 +501,12 @@ namespace Flow.Launcher.Core.Plugin var results = new List(); var metadata = pair.Metadata; + if (IsPluginInitializing(metadata)) + { + // null will be fine since the results will only be added into queue if the token hasn't been cancelled + return null; + } + try { var milliseconds = await PublicApi.Instance.StopwatchLogDebugAsync(ClassName, $"Cost for {metadata.Name}", @@ -482,6 +532,11 @@ namespace Flow.Launcher.Core.Plugin return results; } + private static bool IsPluginInitializing(PluginMetadata metadata) + { + return !_allInitializedPlugins.ContainsKey(metadata.ID); + } + #endregion #region Get Plugin List diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index a51782f40..9ac0b8cb0 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -66,6 +66,8 @@ Position Reset Reset search window position Type here to search + {0}: This plugin is still initializing! + Please wait for a while and select this result to requery Settings