Skip to content

Commit 651e2a9

Browse files
committed
add refresh plugin action keyword display when changed
1 parent 34622d6 commit 651e2a9

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

Flow.Launcher/ActionKeywords.xaml.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
using System.Windows;
1+
using System.Windows;
22
using Flow.Launcher.Core.Plugin;
33
using Flow.Launcher.Core.Resource;
44
using Flow.Launcher.Infrastructure.Exception;
55
using Flow.Launcher.Infrastructure.UserSettings;
66
using Flow.Launcher.Plugin;
7+
using Flow.Launcher.ViewModel;
78

89
namespace Flow.Launcher
910
{
@@ -12,13 +13,14 @@ public partial class ActionKeywords : Window
1213
private PluginPair _plugin;
1314
private Settings _settings;
1415
private readonly Internationalization _translater = InternationalizationManager.Instance;
16+
private readonly PluginViewModel pluginViewModel;
1517

16-
public ActionKeywords(string pluginId, Settings settings)
18+
public ActionKeywords(string pluginId, Settings settings, PluginViewModel pluginViewModel)
1719
{
1820
InitializeComponent();
1921
_plugin = PluginManager.GetPluginForId(pluginId);
2022
_settings = settings;
21-
if (_plugin == null)
23+
this.pluginViewModel = pluginViewModel;
2224
{
2325
MessageBox.Show(_translater.GetTranslation("cannotFindSpecifiedPlugin"));
2426
Close();
@@ -41,10 +43,9 @@ private void btnDone_OnClick(object sender, RoutedEventArgs _)
4143
var oldActionKeyword = _plugin.Metadata.ActionKeywords[0];
4244
var newActionKeyword = tbAction.Text.Trim();
4345
newActionKeyword = newActionKeyword.Length > 0 ? newActionKeyword : "*";
44-
if (!PluginManager.ActionKeywordRegistered(newActionKeyword))
46+
if (!pluginViewModel.IsActionKeywordRegistered(newActionKeyword))
4547
{
46-
var id = _plugin.Metadata.ID;
47-
PluginManager.ReplaceActionKeyword(id, oldActionKeyword, newActionKeyword);
48+
pluginViewModel.ChangeActionKeyword(newActionKeyword, oldActionKeyword);
4849
Close();
4950
}
5051
else

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Diagnostics;
33
using System.IO;
44
using System.Windows;
@@ -214,7 +214,7 @@ private void OnPluginActionKeywordsClick(object sender, MouseButtonEventArgs e)
214214
if (e.ChangedButton == MouseButton.Left)
215215
{
216216
var id = _viewModel.SelectedPlugin.PluginPair.Metadata.ID;
217-
ActionKeywords changeKeywordsWindow = new ActionKeywords(id, _settings);
217+
ActionKeywords changeKeywordsWindow = new ActionKeywords(id, _settings, _viewModel.SelectedPlugin);
218218
changeKeywordsWindow.ShowDialog();
219219
}
220220
}

Flow.Launcher/ViewModel/PluginViewModel.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
using System.Windows;
1+
using System.Windows;
22
using System.Windows.Media;
33
using Flow.Launcher.Plugin;
44
using Flow.Launcher.Core.Resource;
55
using Flow.Launcher.Infrastructure.Image;
6+
using Flow.Launcher.Core.Plugin;
67

78
namespace Flow.Launcher.ViewModel
89
{
@@ -25,5 +26,14 @@ public bool PluginState
2526
public string InitilizaTime => string.Format(_translator.GetTranslation("plugin_init_time"), PluginPair.Metadata.InitTime);
2627
public string QueryTime => string.Format(_translator.GetTranslation("plugin_query_time"), PluginPair.Metadata.AvgQueryTime);
2728
public string ActionKeywordsText => string.Join(Query.ActionKeywordSeperater, PluginPair.Metadata.ActionKeywords);
29+
30+
public void ChangeActionKeyword(string newActionKeyword, string oldActionKeyword)
31+
{
32+
PluginManager.ReplaceActionKeyword(PluginPair.Metadata.ID, oldActionKeyword, newActionKeyword);
33+
34+
OnPropertyChanged(nameof(ActionKeywordsText));
35+
}
36+
37+
public bool IsActionKeywordRegistered(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword);
2838
}
2939
}

0 commit comments

Comments
 (0)