Skip to content

Commit 55164ef

Browse files
committed
Improve code quality
1 parent de56814 commit 55164ef

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -273,25 +273,12 @@ public static async Task InitializePluginsAsync(List<PluginPair> allPlugins, IRe
273273
// Register ResultsUpdated event so that plugin query can use results updated interface
274274
register.RegisterResultsUpdatedEvent(pair);
275275

276-
// Register plugin's action keywords so that plugins can be queried in results
277-
// set distinct on each plugin's action keywords helps only firing global(*) and action keywords once where a plugin
278-
// has multiple global and action keywords because we will only add them here once.
279-
foreach (var actionKeyword in pair.Metadata.ActionKeywords.Distinct())
280-
{
281-
switch (actionKeyword)
282-
{
283-
case Query.GlobalPluginWildcardSign:
284-
_globalPlugins.TryAdd(pair.Metadata.ID, pair);
285-
break;
286-
default:
287-
_nonGlobalPlugins.TryAdd(actionKeyword, pair);
288-
break;
289-
}
290-
}
291-
292276
// Update plugin metadata translation after the plugin is initialized with IPublicAPI instance
293277
Internationalization.UpdatePluginMetadataTranslation(pair);
294278

279+
// Register plugin action keywords so that plugins can be queried in results
280+
RegisterPluginActionKeywords(pair);
281+
295282
// Add plugin to Dialog Jump plugin list after the plugin is initialized
296283
DialogJump.InitializeDialogJumpPlugin(pair);
297284

@@ -316,6 +303,24 @@ public static async Task InitializePluginsAsync(List<PluginPair> allPlugins, IRe
316303
}
317304
}
318305

306+
private static void RegisterPluginActionKeywords(PluginPair pair)
307+
{
308+
// set distinct on each plugin's action keywords helps only firing global(*) and action keywords once where a plugin
309+
// has multiple global and action keywords because we will only add them here once.
310+
foreach (var actionKeyword in pair.Metadata.ActionKeywords.Distinct())
311+
{
312+
switch (actionKeyword)
313+
{
314+
case Query.GlobalPluginWildcardSign:
315+
_globalPlugins.TryAdd(pair.Metadata.ID, pair);
316+
break;
317+
default:
318+
_nonGlobalPlugins.TryAdd(actionKeyword, pair);
319+
break;
320+
}
321+
}
322+
}
323+
319324
private static void AddPluginToLists(PluginPair pair)
320325
{
321326
if (pair.Plugin is IContextMenu)

0 commit comments

Comments
 (0)