Don't update view if settings were not changed (#10407)

This commit is contained in:
Mykhailo Pylyp
2021-03-24 16:13:33 +02:00
committed by GitHub
parent 3601492ce1
commit aba97a419c
3 changed files with 29 additions and 13 deletions

View File

@@ -23,5 +23,16 @@ namespace Microsoft.PowerToys.Settings.UI.Library
// By default JsonSerializer will only serialize the properties in the base class. This can be avoided by passing the object type (more details at https://stackoverflow.com/a/62498888)
return JsonSerializer.Serialize(this, GetType());
}
public override int GetHashCode()
{
return ToJsonString().GetHashCode();
}
public override bool Equals(object obj)
{
var settings = obj as BasePTModuleSettings;
return settings?.ToJsonString() == ToJsonString();
}
}
}

View File

@@ -453,5 +453,10 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
{
get => EnablePowerLauncher && !Plugins.Any();
}
public bool IsUpToDate(PowerLauncherSettings settings)
{
return this.settings.Equals(settings);
}
}
}