Fix issue that ActionKeywordRegistered will not exclude old action key

This commit is contained in:
Jack251970 2025-02-21 13:31:46 +08:00
parent f999b97de1
commit 37ad5aa09b
3 changed files with 11 additions and 6 deletions

View file

@ -340,11 +340,11 @@ namespace Flow.Launcher.Core.Plugin
return results;
}
public static bool ActionKeywordRegistered(IReadOnlyList<string> actionKeywords)
public static bool ActionKeywordRegistered(IReadOnlyList<string> newActionKeywords, IReadOnlyList<string> oldActionKeywords)
{
foreach (var actionKeyword in actionKeywords)
foreach (var actionKeyword in newActionKeywords)
{
if (ActionKeywordRegistered(actionKeyword))
if (ActionKeywordRegistered(actionKeyword, oldActionKeywords))
{
return true;
}
@ -352,6 +352,12 @@ namespace Flow.Launcher.Core.Plugin
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

@ -4,6 +4,7 @@ using Flow.Launcher.Plugin;
using Flow.Launcher.ViewModel;
using Flow.Launcher.Core;
using System.Linq;
using Flow.Launcher.Core.Plugin;
namespace Flow.Launcher
{
@ -41,7 +42,7 @@ namespace Flow.Launcher
newActionKeywords = newActionKeywords.Count > 0 ? newActionKeywords : new() { Query.GlobalPluginWildcardSign };
if (!PluginViewModel.IsActionKeywordRegistered(newActionKeywords))
if (!PluginManager.ActionKeywordRegistered(newActionKeywords, oldActionKeywords))
{
pluginViewModel.ChangeActionKeyword(newActionKeywords, oldActionKeywords);
Close();

View file

@ -151,8 +151,6 @@ namespace Flow.Launcher.ViewModel
PluginManager.API.ShowMainWindow();
}
public static bool IsActionKeywordRegistered(IReadOnlyList<string> newActionKeywords) => PluginManager.ActionKeywordRegistered(newActionKeywords);
[RelayCommand]
private void SetActionKeywords()
{