A widget should have only one IWidgetViewModel by default... wondering whether if we should go for the first served, or throw if multiple detected, or ignore the widget
This commit is contained in:
@@ -11,13 +11,10 @@ public class WidgetHostHandler(IMediator mediator) :
|
||||
{
|
||||
if (notification.Value is IWidgetHost host)
|
||||
{
|
||||
if (host.Services.GetRequiredService<IFactory<IWidgetHost, WidgetContainerViewModel?>>() is { } factory)
|
||||
if (host.Services.GetService<IWidgetViewModel>() is IWidgetViewModel viewModel)
|
||||
{
|
||||
if (factory.Create(host) is WidgetContainerViewModel containerViewModel)
|
||||
{
|
||||
await mediator.PublishAsync(new Created<WidgetContainerViewModel>(containerViewModel),
|
||||
nameof(WidgetBarViewModel), cancellationToken);
|
||||
}
|
||||
await mediator.PublishAsync(new Created<IWidgetViewModel>(viewModel),
|
||||
nameof(WidgetViewModel), cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user