Skip to content

Commit 4372b6a

Browse files
committed
Improve code quality
1 parent 507e457 commit 4372b6a

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,16 @@ public static async Task InitializePluginsAsync()
260260
}
261261
}
262262

263-
public static ICollection<PluginPair> ValidPluginsForQuery(Query query)
263+
public static ICollection<PluginPair> ValidPluginsForQuery(Query query, bool quickSwitch)
264264
{
265265
if (query is null)
266266
return Array.Empty<PluginPair>();
267267

268268
if (!NonGlobalPlugins.TryGetValue(query.ActionKeyword, out var plugin))
269-
return GlobalPlugins;
269+
return quickSwitch ? GlobalPlugins.Where(p => p.Plugin is IAsyncQuickSwitch).ToList() : GlobalPlugins;
270+
271+
if (quickSwitch && plugin.Plugin is not IAsyncQuickSwitch)
272+
return Array.Empty<PluginPair>();
270273

271274
return new List<PluginPair>
272275
{

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,13 +1302,7 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
13021302

13031303
_lastQuery = query;
13041304

1305-
var plugins = PluginManager.ValidPluginsForQuery(query);
1306-
1307-
if (quickSwitch)
1308-
{
1309-
// Select for IAsyncQuickSwitch
1310-
plugins = new Collection<PluginPair>(plugins.Where(p => p.Plugin is IAsyncQuickSwitch).ToList());
1311-
}
1305+
var plugins = PluginManager.ValidPluginsForQuery(query, quickSwitch);
13121306

13131307
if (plugins.Count == 1)
13141308
{

0 commit comments

Comments
 (0)