mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 08:19:47 +00:00
Refactor SettingsDialogBase to inherit from MSGComponentBase
This commit is contained in:
parent
c5360ebede
commit
087ab5257c
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
|
using AIStudio.Components;
|
||||||
using AIStudio.Settings;
|
using AIStudio.Settings;
|
||||||
using AIStudio.Tools.Services;
|
using AIStudio.Tools.Services;
|
||||||
|
|
||||||
@ -7,20 +8,14 @@ using Microsoft.AspNetCore.Components;
|
|||||||
|
|
||||||
namespace AIStudio.Dialogs.Settings;
|
namespace AIStudio.Dialogs.Settings;
|
||||||
|
|
||||||
public abstract class SettingsDialogBase : ComponentBase, IMessageBusReceiver, IDisposable
|
public abstract class SettingsDialogBase : MSGComponentBase
|
||||||
{
|
{
|
||||||
[CascadingParameter]
|
[CascadingParameter]
|
||||||
protected IMudDialogInstance MudDialog { get; set; } = null!;
|
protected IMudDialogInstance MudDialog { get; set; } = null!;
|
||||||
|
|
||||||
[Inject]
|
|
||||||
protected SettingsManager SettingsManager { get; init; } = null!;
|
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
protected IDialogService DialogService { get; init; } = null!;
|
protected IDialogService DialogService { get; init; } = null!;
|
||||||
|
|
||||||
[Inject]
|
|
||||||
protected MessageBus MessageBus { get; init; } = null!;
|
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
protected RustService RustService { get; init; } = null!;
|
protected RustService RustService { get; init; } = null!;
|
||||||
|
|
||||||
@ -32,9 +27,7 @@ public abstract class SettingsDialogBase : ComponentBase, IMessageBusReceiver, I
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
// Register this component with the message bus:
|
this.ApplyFilters([], [ Event.CONFIGURATION_CHANGED ]);
|
||||||
this.MessageBus.RegisterComponent(this);
|
|
||||||
this.MessageBus.ApplyFilters(this, [], [ Event.CONFIGURATION_CHANGED ]);
|
|
||||||
|
|
||||||
this.UpdateProviders();
|
this.UpdateProviders();
|
||||||
this.UpdateEmbeddingProviders();
|
this.UpdateEmbeddingProviders();
|
||||||
@ -60,11 +53,9 @@ public abstract class SettingsDialogBase : ComponentBase, IMessageBusReceiver, I
|
|||||||
this.availableEmbeddingProviders.Add(new (provider.Name, provider.Id));
|
this.availableEmbeddingProviders.Add(new (provider.Name, provider.Id));
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Implementation of IMessageBusReceiver
|
#region Overrides of MSGComponentBase
|
||||||
|
|
||||||
public string ComponentName => nameof(Settings);
|
protected override Task ProcessIncomingMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default
|
||||||
|
|
||||||
public Task ProcessMessage<TMsg>(ComponentBase? sendingComponent, Event triggeredEvent, TMsg? data)
|
|
||||||
{
|
{
|
||||||
switch (triggeredEvent)
|
switch (triggeredEvent)
|
||||||
{
|
{
|
||||||
@ -76,19 +67,5 @@ public abstract class SettingsDialogBase : ComponentBase, IMessageBusReceiver, I
|
|||||||
return Task.CompletedTask;
|
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
|
#endregion
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user