Skip to content

Commit de56814

Browse files
committed
Improve code quality
1 parent 445a142 commit de56814

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -270,24 +270,6 @@ public static async Task InitializePluginsAsync(List<PluginPair> allPlugins, IRe
270270
return;
271271
}
272272

273-
// Initialize plugin lists after the plugin is initialized
274-
if (pair.Plugin is IContextMenu)
275-
{
276-
_contextMenuPlugins.Add(pair);
277-
}
278-
if (pair.Plugin is IAsyncHomeQuery)
279-
{
280-
_homePlugins.Add(pair);
281-
}
282-
if (pair.Plugin is IPluginI18n)
283-
{
284-
_translationPlugins.Add(pair);
285-
}
286-
if (pair.Plugin is IAsyncExternalPreview)
287-
{
288-
_externalPreviewPlugins.Add(pair);
289-
}
290-
291273
// Register ResultsUpdated event so that plugin query can use results updated interface
292274
register.RegisterResultsUpdatedEvent(pair);
293275

@@ -313,8 +295,8 @@ public static async Task InitializePluginsAsync(List<PluginPair> allPlugins, IRe
313295
// Add plugin to Dialog Jump plugin list after the plugin is initialized
314296
DialogJump.InitializeDialogJumpPlugin(pair);
315297

316-
// Add plugin to all plugin list
317-
_allPlugins.TryAdd(pair.Metadata.ID, pair);
298+
// Add plugin to lists after the plugin is initialized
299+
AddPluginToLists(pair);
318300
}));
319301

320302
await Task.WhenAll(InitTasks);
@@ -334,6 +316,27 @@ public static async Task InitializePluginsAsync(List<PluginPair> allPlugins, IRe
334316
}
335317
}
336318

319+
private static void AddPluginToLists(PluginPair pair)
320+
{
321+
if (pair.Plugin is IContextMenu)
322+
{
323+
_contextMenuPlugins.Add(pair);
324+
}
325+
if (pair.Plugin is IAsyncHomeQuery)
326+
{
327+
_homePlugins.Add(pair);
328+
}
329+
if (pair.Plugin is IPluginI18n)
330+
{
331+
_translationPlugins.Add(pair);
332+
}
333+
if (pair.Plugin is IAsyncExternalPreview)
334+
{
335+
_externalPreviewPlugins.Add(pair);
336+
}
337+
_allPlugins.TryAdd(pair.Metadata.ID, pair);
338+
}
339+
337340
public static ICollection<PluginPair> ValidPluginsForQuery(Query query, bool dialogJump)
338341
{
339342
if (query is null)

0 commit comments

Comments
 (0)