From 5d67eef57bbce11c496e60b190b3469df09ba489 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 23 Feb 2025 19:43:25 +0800 Subject: [PATCH] Improve code quality --- Flow.Launcher/ActionKeywords.xaml.cs | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/Flow.Launcher/ActionKeywords.xaml.cs b/Flow.Launcher/ActionKeywords.xaml.cs index b0e4edbc1..6ea1dae50 100644 --- a/Flow.Launcher/ActionKeywords.xaml.cs +++ b/Flow.Launcher/ActionKeywords.xaml.cs @@ -42,8 +42,8 @@ namespace Flow.Launcher newActionKeywords = newActionKeywords.Distinct().ToList(); newActionKeywords = newActionKeywords.Count > 0 ? newActionKeywords : new() { Query.GlobalPluginWildcardSign }; - - if (!ActionKeywordRegistered(newActionKeywords, oldActionKeywords)) + + if (!newActionKeywords.Except(oldActionKeywords).Any(PluginManager.ActionKeywordRegistered)) { pluginViewModel.ChangeActionKeyword(newActionKeywords, oldActionKeywords); Close(); @@ -54,24 +54,5 @@ namespace Flow.Launcher MessageBoxEx.Show(msg); } } - - private static bool ActionKeywordRegistered(IReadOnlyList newActionKeywords, IReadOnlyList 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; - } } }