Fixed more edge cases

This commit is contained in:
TheXamlGuy
2024-05-21 20:32:42 +01:00
parent 1190303044
commit 83fef5e399
18 changed files with 153 additions and 63 deletions
+17 -4
View File
@@ -8,12 +8,25 @@ public class NavigateHandler(NamedComponent scope,
{
public Task Handle(NavigateEventArgs args)
{
INavigationScope? navigationScope;
if (args.Scope == "self" && args.Sender is IServiceProviderRequired requireServiceProvider)
INavigationScope? navigationScope = null;
if (args.Scope is "self" || args.Scope is "new")
{
navigationScope = requireServiceProvider.Provider.GetRequiredService<INavigationScope>();
if (args.Sender is IServiceProviderRequired requireServiceProvider)
{
if (args.Scope is "self")
{
navigationScope = requireServiceProvider.Provider.GetRequiredService<INavigationScope>();
}
if (args.Scope is "new")
{
IServiceScope serviceScope = requireServiceProvider.Provider.CreateScope();
navigationScope = serviceScope.ServiceProvider.GetRequiredService<INavigationScope>();
}
}
}
else
if (navigationScope is null)
{
ComponentScopeDescriptor? descriptor = componentScopeProvider.Get(args.Scope ?? scope.Name);
navigationScope = descriptor?.Services?.GetRequiredService<INavigationScope>();