Skip to content

Commit 2c96467

Browse files
committed
Fix QueryTime won't change by adding fody to Flow.Launcher.Plugin.csproj and add a delegate to trigger update once the avgquerytime is changed through querying
1 parent da12a06 commit 2c96467

File tree

4 files changed

+30
-20
lines changed

4 files changed

+30
-20
lines changed

Flow.Launcher.Plugin/Flow.Launcher.Plugin.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,13 @@
6060
</ItemGroup>
6161

6262
<ItemGroup>
63+
<PackageReference Include="Fody" Version="6.5.4">
64+
<PrivateAssets>all</PrivateAssets>
65+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
66+
</PackageReference>
6367
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
6468
<PackageReference Include="JetBrains.Annotations" Version="2021.2.0" />
69+
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0" />
6570
</ItemGroup>
6671

6772
</Project>

Flow.Launcher/ActionKeywords.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private void btnDone_OnClick(object sender, RoutedEventArgs _)
4444
var oldActionKeyword = plugin.Metadata.ActionKeywords[0];
4545
var newActionKeyword = tbAction.Text.Trim();
4646
newActionKeyword = newActionKeyword.Length > 0 ? newActionKeyword : "*";
47-
if (!pluginViewModel.IsActionKeywordRegistered(newActionKeyword))
47+
if (!PluginViewModel.IsActionKeywordRegistered(newActionKeyword))
4848
{
4949
pluginViewModel.ChangeActionKeyword(newActionKeyword, oldActionKeyword);
5050
Close();

Flow.Launcher/Flow.Launcher.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@
8383
</ItemGroup>
8484

8585
<ItemGroup>
86+
<PackageReference Include="Fody" Version="6.5.4">
87+
<PrivateAssets>all</PrivateAssets>
88+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
89+
</PackageReference>
8690
<PackageReference Include="InputSimulator" Version="1.0.4" />
8791
<PackageReference Include="ModernWpfUI" Version="0.9.4" />
8892
<PackageReference Include="NHotkey.Wpf" Version="2.1.0" />

Flow.Launcher/ViewModel/PluginViewModel.cs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,39 @@ namespace Flow.Launcher.ViewModel
99
{
1010
public class PluginViewModel : BaseModel
1111
{
12-
public PluginPair PluginPair { get; set; }
13-
14-
public ImageSource Image => ImageLoader.Load(PluginPair.Metadata.IcoPath);
15-
public bool PluginState
12+
private readonly PluginPair _pluginPair;
13+
public PluginPair PluginPair
1614
{
17-
get { return !PluginPair.Metadata.Disabled; }
18-
set
15+
get => _pluginPair;
16+
init
1917
{
20-
PluginPair.Metadata.Disabled = !value;
18+
_pluginPair = value;
19+
value.Metadata.PropertyChanged += (_, args) =>
20+
{
21+
if (args.PropertyName == nameof(PluginPair.Metadata.AvgQueryTime))
22+
OnPropertyChanged(nameof(QueryTime));
23+
};
2124
}
2225
}
2326

24-
public Control SettingControl
27+
public ImageSource Image => ImageLoader.Load(PluginPair.Metadata.IcoPath);
28+
public bool PluginState
2529
{
26-
get
27-
{
28-
if (PluginPair.Plugin is not ISettingProvider settingProvider)
29-
return new Control();
30-
31-
return settingProvider.CreateSettingPanel();
32-
}
30+
get => !PluginPair.Metadata.Disabled;
31+
set => PluginPair.Metadata.Disabled = !value;
3332
}
3433

34+
public Control SettingControl => PluginPair.Plugin is not ISettingProvider settingProvider ? new Control() : settingProvider.CreateSettingPanel();
35+
3536
public Visibility ActionKeywordsVisibility => PluginPair.Metadata.ActionKeywords.Count == 1 ? Visibility.Visible : Visibility.Collapsed;
36-
public string InitilizaTime => PluginPair.Metadata.InitTime.ToString() + "ms";
37+
public string InitilizaTime => PluginPair.Metadata.InitTime + "ms";
3738
public string QueryTime => PluginPair.Metadata.AvgQueryTime + "ms";
3839
public string ActionKeywordsText => string.Join(Query.ActionKeywordSeperater, PluginPair.Metadata.ActionKeywords);
3940
public int Priority => PluginPair.Metadata.Priority;
4041

4142
public void ChangeActionKeyword(string newActionKeyword, string oldActionKeyword)
4243
{
4344
PluginManager.ReplaceActionKeyword(PluginPair.Metadata.ID, oldActionKeyword, newActionKeyword);
44-
4545
OnPropertyChanged(nameof(ActionKeywordsText));
4646
}
4747

@@ -51,6 +51,7 @@ public void ChangePriority(int newPriority)
5151
OnPropertyChanged(nameof(Priority));
5252
}
5353

54-
public bool IsActionKeywordRegistered(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword);
54+
public static bool IsActionKeywordRegistered(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword);
5555
}
56-
}
56+
57+
}

0 commit comments

Comments
 (0)