Skip to content

Commit

Permalink
Update NavigationContext leafContext to be safe for Fragments which a…
Browse files Browse the repository at this point in the history
…re not yet fully created
  • Loading branch information
isaac-udy committed Apr 25, 2024
1 parent 470177a commit e43cc14
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions enro-core/src/main/java/dev/enro/core/NavigationContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,9 @@ public fun NavigationContext<*>.leafContext(): NavigationContext<*> {
else -> null
}
return containerManager.activeContainer?.childContext?.leafContext()
?: fragmentManager?.primaryNavigationFragment?.navigationContext?.leafContext()
?: runCatching { fragmentManager?.primaryNavigationFragment?.navigationContext }.getOrNull()?.leafContext()
?: this
}

public val ComponentActivity.containerManager: NavigationContainerManager get() = navigationContext.containerManager
public val Fragment.containerManager: NavigationContainerManager get() = navigationContext.containerManager
public val ComposableDestination.containerManager: NavigationContainerManager get() = navigationContext.containerManager
Expand Down

0 comments on commit e43cc14

Please sign in to comment.