@@ -24,9 +24,6 @@ public static class PluginManager
24
24
{
25
25
private static readonly string ClassName = nameof ( PluginManager ) ;
26
26
27
- private static IEnumerable < PluginPair > _contextMenuPlugins ;
28
- private static IEnumerable < PluginPair > _homePlugins ;
29
-
30
27
public static List < PluginPair > AllPlugins { get ; private set ; }
31
28
public static readonly HashSet < PluginPair > GlobalPlugins = new ( ) ;
32
29
public static readonly Dictionary < string , PluginPair > NonGlobalPlugins = new ( ) ;
@@ -36,8 +33,11 @@ public static class PluginManager
36
33
private static IPublicAPI API => api ??= Ioc . Default . GetRequiredService < IPublicAPI > ( ) ;
37
34
38
35
private static PluginsSettings Settings ;
39
- private static List < PluginMetadata > _metadatas ;
40
- private static readonly List < string > _modifiedPlugins = new ( ) ;
36
+
37
+ private static IEnumerable < PluginPair > _contextMenuPlugins ;
38
+ private static IEnumerable < PluginPair > _homePlugins ;
39
+ private static IEnumerable < PluginPair > _resultUpdatePlugin ;
40
+ private static IEnumerable < PluginPair > _translationPlugins ;
41
41
42
42
/// <summary>
43
43
/// Directories that will hold Flow Launcher plugin directory
@@ -162,12 +162,18 @@ static PluginManager()
162
162
/// <param name="settings"></param>
163
163
public static void LoadPlugins ( PluginsSettings settings )
164
164
{
165
- _metadatas = PluginConfig . Parse ( Directories ) ;
165
+ var metadatas = PluginConfig . Parse ( Directories ) ;
166
166
Settings = settings ;
167
- Settings . UpdatePluginSettings ( _metadatas ) ;
168
- AllPlugins = PluginsLoader . Plugins ( _metadatas , Settings ) ;
167
+ Settings . UpdatePluginSettings ( metadatas ) ;
168
+ AllPlugins = PluginsLoader . Plugins ( metadatas , Settings ) ;
169
169
// Since dotnet plugins need to get assembly name first, we should update plugin directory after loading plugins
170
- UpdatePluginDirectory ( _metadatas ) ;
170
+ UpdatePluginDirectory ( metadatas ) ;
171
+
172
+ // Initialize plugin enumerable after all plugins are initialized
173
+ _contextMenuPlugins = GetPluginsForInterface < IContextMenu > ( ) ;
174
+ _homePlugins = GetPluginsForInterface < IAsyncHomeQuery > ( ) ;
175
+ _resultUpdatePlugin = GetPluginsForInterface < IResultUpdated > ( ) ;
176
+ _translationPlugins = GetPluginsForInterface < IPluginI18n > ( ) ;
171
177
}
172
178
173
179
private static void UpdatePluginDirectory ( List < PluginMetadata > metadatas )
@@ -237,9 +243,6 @@ public static async Task InitializePluginsAsync()
237
243
238
244
await Task . WhenAll ( InitTasks ) ;
239
245
240
- _contextMenuPlugins = GetPluginsForInterface < IContextMenu > ( ) ;
241
- _homePlugins = GetPluginsForInterface < IAsyncHomeQuery > ( ) ;
242
-
243
246
foreach ( var plugin in AllPlugins )
244
247
{
245
248
// set distinct on each plugin's action keywords helps only firing global(*) and action keywords once where a plugin
@@ -393,12 +396,22 @@ public static PluginPair GetPluginForId(string id)
393
396
return AllPlugins . FirstOrDefault ( o => o . Metadata . ID == id ) ;
394
397
}
395
398
396
- public static IEnumerable < PluginPair > GetPluginsForInterface < T > ( ) where T : IFeatures
399
+ private static IEnumerable < PluginPair > GetPluginsForInterface < T > ( ) where T : IFeatures
397
400
{
398
401
// Handle scenario where this is called before all plugins are instantiated, e.g. language change on startup
399
402
return AllPlugins ? . Where ( p => p . Plugin is T ) ?? Array . Empty < PluginPair > ( ) ;
400
403
}
401
404
405
+ public static IList < PluginPair > GetResultUpdatePlugin ( )
406
+ {
407
+ return _resultUpdatePlugin . ToList ( ) ;
408
+ }
409
+
410
+ public static IList < PluginPair > GetTranslationPlugins ( )
411
+ {
412
+ return _translationPlugins . ToList ( ) ;
413
+ }
414
+
402
415
public static List < Result > GetContextMenusForPlugin ( Result result )
403
416
{
404
417
var results = new List < Result > ( ) ;
0 commit comments