Check old action keyword out of PluginManager

This commit is contained in:
Jack251970 2025-02-23 14:06:58 +08:00
parent 87febda78f
commit 34cb078602
2 changed files with 21 additions and 19 deletions

View file

@ -340,24 +340,6 @@ namespace Flow.Launcher.Core.Plugin
return results;
}
public static bool ActionKeywordRegistered(IReadOnlyList<string> newActionKeywords, IReadOnlyList<string> oldActionKeywords)
{
foreach (var actionKeyword in newActionKeywords)
{
if (ActionKeywordRegistered(actionKeyword, oldActionKeywords))
{
return true;
}
}
return false;
}
private static bool ActionKeywordRegistered(string actionKeyword, IReadOnlyList<string> oldActionKeywords)
{
if (oldActionKeywords.Contains(actionKeyword)) return false;
return ActionKeywordRegistered(actionKeyword);
}
public static bool ActionKeywordRegistered(string actionKeyword)
{
// this method is only checking for action keywords (defined as not '*') registration

View file

@ -5,6 +5,7 @@ using Flow.Launcher.ViewModel;
using Flow.Launcher.Core;
using System.Linq;
using Flow.Launcher.Core.Plugin;
using System.Collections.Generic;
namespace Flow.Launcher
{
@ -42,7 +43,7 @@ namespace Flow.Launcher
newActionKeywords = newActionKeywords.Count > 0 ? newActionKeywords : new() { Query.GlobalPluginWildcardSign };
if (!PluginManager.ActionKeywordRegistered(newActionKeywords, oldActionKeywords))
if (!ActionKeywordRegistered(newActionKeywords, oldActionKeywords))
{
pluginViewModel.ChangeActionKeyword(newActionKeywords, oldActionKeywords);
Close();
@ -53,5 +54,24 @@ namespace Flow.Launcher
MessageBoxEx.Show(msg);
}
}
private static bool ActionKeywordRegistered(IReadOnlyList<string> newActionKeywords, IReadOnlyList<string> oldActionKeywords)
{
foreach (var actionKeyword in newActionKeywords)
{
// We need to check if this new action keyword is from the old action keywords because
// we have not changed action keyword yet so PluginManager still has the old action keywords
if (oldActionKeywords.Contains(actionKeyword))
{
continue;
}
if (PluginManager.ActionKeywordRegistered(actionKeyword))
{
return true;
}
}
return false;
}
}
}