Skip to content

Commit f5a49ff

Browse files
Settings dialogs must be updated when settings are changed (#360)
1 parent a5863a1 commit f5a49ff

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

app/MindWork AI Studio/Dialogs/Settings/SettingsDialogBase.cs

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace AIStudio.Dialogs.Settings;
99

10-
public abstract class SettingsDialogBase : ComponentBase
10+
public abstract class SettingsDialogBase : ComponentBase, IMessageBusReceiver, IDisposable
1111
{
1212
[CascadingParameter]
1313
protected IMudDialogInstance MudDialog { get; set; } = null!;
@@ -30,11 +30,15 @@ public abstract class SettingsDialogBase : ComponentBase
3030
#region Overrides of ComponentBase
3131

3232
/// <inheritdoc />
33-
protected override void OnInitialized()
33+
protected override async Task OnInitializedAsync()
3434
{
35+
// Register this component with the message bus:
36+
this.MessageBus.RegisterComponent(this);
37+
this.MessageBus.ApplyFilters(this, [], [ Event.CONFIGURATION_CHANGED ]);
38+
3539
this.UpdateProviders();
3640
this.UpdateEmbeddingProviders();
37-
base.OnInitialized();
41+
await base.OnInitializedAsync();
3842
}
3943

4044
#endregion
@@ -55,4 +59,36 @@ private void UpdateEmbeddingProviders()
5559
foreach (var provider in this.SettingsManager.ConfigurationData.EmbeddingProviders)
5660
this.availableEmbeddingProviders.Add(new (provider.Name, provider.Id));
5761
}
62+
63+
#region Implementation of IMessageBusReceiver
64+
65+
public string ComponentName => nameof(Settings);
66+
67+
public Task ProcessMessage<TMsg>(ComponentBase? sendingComponent, Event triggeredEvent, TMsg? data)
68+
{
69+
switch (triggeredEvent)
70+
{
71+
case Event.CONFIGURATION_CHANGED:
72+
this.StateHasChanged();
73+
break;
74+
}
75+
76+
return Task.CompletedTask;
77+
}
78+
79+
public Task<TResult?> ProcessMessageWithResult<TPayload, TResult>(ComponentBase? sendingComponent, Event triggeredEvent, TPayload? data)
80+
{
81+
return Task.FromResult<TResult?>(default);
82+
}
83+
84+
#endregion
85+
86+
#region Implementation of IDisposable
87+
88+
public void Dispose()
89+
{
90+
this.MessageBus.Unregister(this);
91+
}
92+
93+
#endregion
5894
}

app/MindWork AI Studio/wwwroot/changelog/v0.9.37.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
- Moved the data source settings into the data selection component.
55
- Fixed the "send to" menu position, which was offset due to the MudBlazor 8 upgrade.
66
- Fixed a rare issue with the enum selection component, where the `SelectionUpdated` function was not called for the special `other` enum values.
7+
- Fixed the new setting dialogs, which were not updated appropriately when settings were changed.
78
- Removed the link to the ERI server assistant from its settings page, as it is no longer necessary.

0 commit comments

Comments
 (0)