Skip to content

Commit f999b97

Browse files
committed
Fix build issue
1 parent d9ba38b commit f999b97

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,17 @@ public static List<Result> GetContextMenusForPlugin(Result result)
342342

343343
public static bool ActionKeywordRegistered(IReadOnlyList<string> actionKeywords)
344344
{
345-
return actionKeywords.Any(ActionKeywordRegistered);
345+
foreach (var actionKeyword in actionKeywords)
346+
{
347+
if (ActionKeywordRegistered(actionKeyword))
348+
{
349+
return true;
350+
}
351+
}
352+
return false;
346353
}
347354

348-
private static bool ActionKeywordRegistered(string actionKeyword)
355+
public static bool ActionKeywordRegistered(string actionKeyword)
349356
{
350357
// this method is only checking for action keywords (defined as not '*') registration
351358
// hence the actionKeyword != Query.GlobalPluginWildcardSign logic
@@ -369,6 +376,7 @@ public static void AddActionKeyword(string id, string newActionKeyword)
369376
NonGlobalPlugins[newActionKeyword] = plugin;
370377
}
371378

379+
// Update action keywords in plugin metadata
372380
plugin.Metadata.ActionKeywords.Add(newActionKeyword);
373381
}
374382

@@ -390,27 +398,28 @@ public static void RemoveActionKeyword(string id, string oldActionkeyword)
390398
if (oldActionkeyword != Query.GlobalPluginWildcardSign)
391399
NonGlobalPlugins.Remove(oldActionkeyword);
392400

401+
// Update action keywords in plugin metadata
393402
plugin.Metadata.ActionKeywords.Remove(oldActionkeyword);
394403
}
395404

396-
public static void ReplaceActionKeyword(string id, IReadOnlyList<string> oldActionKeyword, IReadOnlyList<string> newActionKeyword)
405+
public static void ReplaceActionKeyword(string id, IReadOnlyList<string> oldActionKeywords, IReadOnlyList<string> newActionKeywords)
397406
{
398-
if (CheckActionKeywordChanged(oldActionKeyword, newActionKeyword))
407+
if (CheckActionKeywordChanged(oldActionKeywords, newActionKeywords))
399408
{
400-
foreach (var actionKeyword in newActionKeyword)
409+
foreach (var actionKeyword in newActionKeywords)
401410
{
402411
AddActionKeyword(id, actionKeyword);
403412
}
404-
foreach (var actionKeyword in oldActionKeyword)
413+
foreach (var actionKeyword in oldActionKeywords)
405414
{
406415
RemoveActionKeyword(id, actionKeyword);
407416
}
408417

409418
// Update action keyword in plugin metadata
410419
var plugin = GetPluginForId(id);
411-
if (newActionKeyword.Count > 0)
420+
if (newActionKeywords.Count > 0)
412421
{
413-
plugin.Metadata.ActionKeyword = newActionKeyword[0];
422+
plugin.Metadata.ActionKeyword = newActionKeywords[0];
414423
}
415424
else
416425
{
@@ -426,6 +435,27 @@ private static bool CheckActionKeywordChanged(IReadOnlyList<string> oldActionKey
426435
return oldActionKeyword.Where((t, i) => t != newActionKeyword[i]).Any();
427436
}
428437

438+
public static void ReplaceActionKeyword(string id, string oldActionKeyword, string newActionKeyword)
439+
{
440+
if (oldActionKeyword != newActionKeyword)
441+
{
442+
AddActionKeyword(id, newActionKeyword);
443+
RemoveActionKeyword(id, oldActionKeyword);
444+
445+
// Update action keyword in plugin metadata
446+
var plugin = GetPluginForId(id);
447+
var newActionKeywords = plugin.Metadata.ActionKeywords;
448+
if (newActionKeywords.Count > 0)
449+
{
450+
plugin.Metadata.ActionKeyword = newActionKeywords[0];
451+
}
452+
else
453+
{
454+
plugin.Metadata.ActionKeyword = string.Empty;
455+
}
456+
}
457+
}
458+
429459
private static string GetContainingFolderPathAfterUnzip(string unzippedParentFolderPath)
430460
{
431461
var unzippedFolderCount = Directory.GetDirectories(unzippedParentFolderPath).Length;

Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private void OnConfirmButtonClick(object sender, RoutedEventArgs e)
8080
private void AddSearchSource()
8181
{
8282
var keyword = _searchSource.ActionKeyword;
83-
if (!PluginManager.ActionKeywordRegistered(keyword))
83+
if (!_context.API.ActionKeywordAssigned(keyword))
8484
{
8585
var id = _context.CurrentPluginMetadata.ID;
8686
PluginManager.AddActionKeyword(id, keyword);
@@ -100,7 +100,7 @@ private void EditSearchSource()
100100
{
101101
var newKeyword = _searchSource.ActionKeyword;
102102
var oldKeyword = _oldSearchSource.ActionKeyword;
103-
if (!PluginManager.ActionKeywordRegistered(newKeyword) || oldKeyword == newKeyword)
103+
if (!_context.API.ActionKeywordAssigned(newKeyword) || oldKeyword == newKeyword)
104104
{
105105
var id = _context.CurrentPluginMetadata.ID;
106106
PluginManager.ReplaceActionKeyword(id, oldKeyword, newKeyword);

0 commit comments

Comments
 (0)