From 24fe5a11f98ec09b6f303df1718666d4d6610fbd Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Wed, 26 Aug 2020 08:06:10 +1000 Subject: [PATCH] prevent user from using global action keyword for content search would bring up too many results --- .../Flow.Launcher.Plugin.Explorer/Languages/en.xaml | 1 + .../ViewModels/SettingsViewModel.cs | 2 ++ .../Views/ActionKeywordSetting.xaml.cs | 11 ++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index b7710d332..2fb16e0e1 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -9,6 +9,7 @@ Are you sure you want to permanently delete this {0}? Deletion successful Successfully deleted the {0} + Assigning the global action keyword could bring up too many results during search. Please choose a specific action keyword Delete diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs index e14a6ebb5..7fcd77f07 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs @@ -54,5 +54,7 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels } internal bool IsActionKeywordAlreadyAssigned(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword); + + internal bool IsNewActionKeywordGlobal(string newActionKeyword) => newActionKeyword == Query.GlobalPluginWildcardSign; } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs index b9e5373b7..2957283ad 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs @@ -51,8 +51,17 @@ namespace Flow.Launcher.Plugin.Explorer.Views return; } + + if (settingsViewModel.IsNewActionKeywordGlobal(newActionKeyword) + && currentActionKeyword.Description + == settingsViewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_filecontentsearch")) + { + MessageBox.Show(settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid")); + + return; + } - if(!settingsViewModel.IsActionKeywordAlreadyAssigned(newActionKeyword)) + if (!settingsViewModel.IsActionKeywordAlreadyAssigned(newActionKeyword)) { settingsViewModel.UpdateActionKeyword(newActionKeyword, currentActionKeyword.Keyword);