From 7e49c3c68c693cee27f017c7d45489ff4d17eecc Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Mon, 5 Aug 2024 20:43:12 +0200 Subject: [PATCH] Fixed min/max handling --- .../Blocks/ConfigurationSlider.razor.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/MindWork AI Studio/Components/Blocks/ConfigurationSlider.razor.cs b/app/MindWork AI Studio/Components/Blocks/ConfigurationSlider.razor.cs index 0df46f3d..238aad3d 100644 --- a/app/MindWork AI Studio/Components/Blocks/ConfigurationSlider.razor.cs +++ b/app/MindWork AI Studio/Components/Blocks/ConfigurationSlider.razor.cs @@ -42,10 +42,35 @@ public partial class ConfigurationSlider : ConfigurationBase where T : struct [Parameter] public Action ValueUpdate { get; set; } = _ => { }; + #region Overrides of ComponentBase + + protected override async Task OnInitializedAsync() + { + await this.EnsureMinMax(); + await base.OnInitializedAsync(); + } + + protected override async Task OnParametersSetAsync() + { + await this.EnsureMinMax(); + await base.OnParametersSetAsync(); + } + + #endregion + private async Task OptionChanged(T updatedValue) { this.ValueUpdate(updatedValue); await this.SettingsManager.StoreSettings(); await this.InformAboutChange(); } + + private async Task EnsureMinMax() + { + if (this.Value() < this.Min) + await this.OptionChanged(this.Min); + + else if(this.Value() > this.Max) + await this.OptionChanged(this.Max); + } } \ No newline at end of file