Skip to content

Commit

Permalink
fix: Navigate once when starting app with same route as navigated
Browse files Browse the repository at this point in the history
  • Loading branch information
eriklimakc committed Dec 10, 2024
1 parent 44e66c1 commit ae9c07f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/Uno.Extensions.Navigation.UI/FrameworkElementExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.Extensions.DependencyInjection;

namespace Uno.Extensions.Navigation;
namespace Uno.Extensions.Navigation;

public static class FrameworkElementExtensions
{
Expand Down Expand Up @@ -35,11 +33,12 @@ public static Task HostAsync(
{
var initialNavigation = () => nav.NavigateRouteAsync(root, initialRoute ?? string.Empty);

Route? launchRoute = default;
var start = () => Task.CompletedTask;
var hostConfigOptions = sp.GetService<IOptions<HostConfiguration>>();
if (hostConfigOptions?.Value is { } hostConfig &&
hostConfig.LaunchRoute() is { } launchRoute &&
launchRoute.IsEmpty() == false)
(launchRoute = hostConfig.LaunchRoute()) is { } &&
!launchRoute.IsEmpty())
{
start = () => nav.NavigateRouteAsync(root, launchRoute.FullPath());
}
Expand All @@ -57,8 +56,13 @@ public static Task HostAsync(
}
var fullstart = async () =>
{
await initialNavigation();
await start();
var response = await initialNavigation();

if (launchRoute is null ||
!launchRoute.FullPath().Equals(response?.Route?.FullPath()))
{
await start();
}
};
var startupTask = elementRegion.Services!.Startup(fullstart);
return startupTask;
Expand Down

0 comments on commit ae9c07f

Please sign in to comment.