Refactor Plugins component to streamline message handling

This commit is contained in:
Thorsten Sommer 2025-04-17 12:57:47 +02:00
parent 087ab5257c
commit fd25f14c47
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -1,6 +1,8 @@
using AIStudio.Components;
using AIStudio.Tools.PluginSystem;
using Microsoft.AspNetCore.Components;
namespace AIStudio.Pages;
public partial class Plugins : MSGComponentBase
@ -15,8 +17,7 @@ public partial class Plugins : MSGComponentBase
protected override async Task OnInitializedAsync()
{
this.MessageBus.RegisterComponent(this);
this.MessageBus.ApplyFilters(this, [], [ Event.PLUGINS_RELOADED ]);
this.ApplyFilters([], [ Event.PLUGINS_RELOADED ]);
this.groupConfig = new TableGroupDefinition<IPluginMetadata>
{
@ -48,4 +49,18 @@ public partial class Plugins : MSGComponentBase
await this.SettingsManager.StoreSettings();
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
}
#region Overrides of MSGComponentBase
protected override async Task ProcessIncomingMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default
{
switch (triggeredEvent)
{
case Event.PLUGINS_RELOADED:
await this.InvokeAsync(this.StateHasChanged);
break;
}
}
#endregion
}