don't save windows that haven't changed

This commit is contained in:
goat 2025-01-02 17:21:57 +01:00
parent cac76f045b
commit d22ff8fad8
2 changed files with 19 additions and 1 deletions

View file

@ -49,5 +49,13 @@ internal class PresetModel
/// </summary>
[JsonProperty("a")]
public float? Alpha { get; set; }
/// <summary>
/// Gets a value indicating whether this preset is in the default state.
/// </summary>
public bool IsDefault =>
!this.IsPinned &&
!this.IsClickThrough &&
!this.Alpha.HasValue;
}
}

View file

@ -41,7 +41,17 @@ internal class WindowSystemPersistence : IServiceType
/// <param name="window">The preset window instance.</param>
public void SaveWindow(uint id, PresetModel.PresetWindow window)
{
this.ActivePreset.Windows[id] = window;
// If the window is in the default state, don't save it to avoid saving every possible window
// if the user has not customized anything.
if (window.IsDefault)
{
this.ActivePreset.Windows.Remove(id);
}
else
{
this.ActivePreset.Windows[id] = window;
}
this.config.QueueSave();
}
}