Fixed the new setting dialogs, which were not updated appropriately when settings were changed

This commit is contained in:
Thorsten Sommer 2025-03-16 21:03:29 +01:00
parent a5863a176c
commit b2c14820bb
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 40 additions and 3 deletions

View File

@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Components;
namespace AIStudio.Dialogs.Settings;
public abstract class SettingsDialogBase : ComponentBase
public abstract class SettingsDialogBase : ComponentBase, IMessageBusReceiver, IDisposable
{
[CascadingParameter]
protected IMudDialogInstance MudDialog { get; set; } = null!;
@ -30,11 +30,15 @@ public abstract class SettingsDialogBase : ComponentBase
#region Overrides of ComponentBase
/// <inheritdoc />
protected override void OnInitialized()
protected override async Task OnInitializedAsync()
{
// Register this component with the message bus:
this.MessageBus.RegisterComponent(this);
this.MessageBus.ApplyFilters(this, [], [ Event.CONFIGURATION_CHANGED ]);
this.UpdateProviders();
this.UpdateEmbeddingProviders();
base.OnInitialized();
await base.OnInitializedAsync();
}
#endregion
@ -55,4 +59,36 @@ public abstract class SettingsDialogBase : ComponentBase
foreach (var provider in this.SettingsManager.ConfigurationData.EmbeddingProviders)
this.availableEmbeddingProviders.Add(new (provider.Name, provider.Id));
}
#region Implementation of IMessageBusReceiver
public string ComponentName => nameof(Settings);
public Task ProcessMessage<TMsg>(ComponentBase? sendingComponent, Event triggeredEvent, TMsg? data)
{
switch (triggeredEvent)
{
case Event.CONFIGURATION_CHANGED:
this.StateHasChanged();
break;
}
return Task.CompletedTask;
}
public Task<TResult?> ProcessMessageWithResult<TPayload, TResult>(ComponentBase? sendingComponent, Event triggeredEvent, TPayload? data)
{
return Task.FromResult<TResult?>(default);
}
#endregion
#region Implementation of IDisposable
public void Dispose()
{
this.MessageBus.Unregister(this);
}
#endregion
}

View File

@ -4,4 +4,5 @@
- Moved the data source settings into the data selection component.
- Fixed the "send to" menu position, which was offset due to the MudBlazor 8 upgrade.
- Fixed a rare issue with the enum selection component, where the `SelectionUpdated` function was not called for the special `other` enum values.
- Fixed the new setting dialogs, which were not updated appropriately when settings were changed.
- Removed the link to the ERI server assistant from its settings page, as it is no longer necessary.