[PTRun][Settings][Program] Fix 100% CPU load issue (#17414)

* [PTRun][Program]Don't reload on settings change

* [PTRun][Settings] Don't trigger saves on visual property changes

* [PTRun][Settings] Fix manipulation of searched plugins

* [PTRun][Settings] Don't reload settings if we wrote recently

* fix PR comments nit
This commit is contained in:
Jaime Bernardo
2022-04-01 14:50:16 +01:00
committed by GitHub
parent 172c63f1e2
commit 04588bc7e0
3 changed files with 31 additions and 7 deletions

View File

@@ -104,6 +104,15 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private void OnPluginInfoChange(object sender, PropertyChangedEventArgs e)
{
if (
e.PropertyName == nameof(PowerLauncherPluginViewModel.ShowNotAccessibleWarning)
|| e.PropertyName == nameof(PowerLauncherPluginViewModel.ShowNotAllowedKeywordWarning)
)
{
// Don't trigger a settings update if the changed property is for visual notification.
return;
}
OnPropertyChanged(nameof(ShowAllPluginsDisabledWarning));
UpdateSettings();
}
@@ -430,6 +439,10 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
{
var plugins = settings.Plugins.Where(p => p.Name.StartsWith(SearchText, StringComparison.OrdinalIgnoreCase) || p.Name.IndexOf($" {SearchText}", StringComparison.OrdinalIgnoreCase) > 0);
_plugins = new ObservableCollection<PowerLauncherPluginViewModel>(plugins.Select(x => new PowerLauncherPluginViewModel(x, isDark)));
foreach (var plugin in _plugins)
{
plugin.PropertyChanged += OnPluginInfoChange;
}
}
else
{