Added possibility to inform the entire system about changed settings

This commit is contained in:
tsommer committed 2024-07-24 14:15:46 +02:00
1 parent c12bfa5a25
commit 9d28d8379e
4 files changed
+10 -1

No files matched your search

@@ -1,4 +1,5 @@
using AIStudio.Settings;
using AIStudio.Tools;
using Microsoft.AspNetCore.Components;
@@ -23,7 +24,12 @@ public partial class ConfigurationBase : ComponentBase
public string OptionHelp { get; set; } = string.Empty;
[Inject]
public SettingsManager SettingsManager { get; init; } = null!;
protected SettingsManager SettingsManager { get; init; } = null!;
[Inject]
protected MessageBus MessageBus { get; init; } = null!;
protected const string MARGIN_CLASS = "mb-6";
protected async Task InformAboutChange() => await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
}
@@ -35,5 +35,6 @@ public partial class ConfigurationOption : ConfigurationBase
{
this.StateUpdate(updatedState);
await this.SettingsManager.StoreSettings();
await this.InformAboutChange();
}
}
@@ -30,6 +30,7 @@ public partial class ConfigurationSelect<T> : ConfigurationBase
{
this.SelectionUpdate(updatedValue);
await this.SettingsManager.StoreSettings();
await this.InformAboutChange();
}
private static string GetClass => $"{MARGIN_CLASS} rounded-lg";
+1
View File
@@ -6,6 +6,7 @@ public enum Event
// Common events:
STATE_HAS_CHANGED,
CONFIGURATION_CHANGED,
// Update events:
USER_SEARCH_FOR_UPDATE,