Fix navigation context
This commit is contained in:
+2
-10
@@ -136,7 +136,7 @@ import {
|
|||||||
EmailDialogScreenID,
|
EmailDialogScreenID,
|
||||||
useEmailDialogControl,
|
useEmailDialogControl,
|
||||||
} from '#/components/dialogs/EmailDialog'
|
} from '#/components/dialogs/EmailDialog'
|
||||||
import {AnalyticsContext, useAnalytics, utils} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
import {IS_NATIVE, IS_WEB} from '#/env'
|
import {IS_NATIVE, IS_WEB} from '#/env'
|
||||||
import {router} from '#/routes'
|
import {router} from '#/routes'
|
||||||
import {Referrer} from '../modules/expo-bluesky-swiss-army'
|
import {Referrer} from '../modules/expo-bluesky-swiss-army'
|
||||||
@@ -1065,15 +1065,7 @@ function RoutesContainer({children}: React.PropsWithChildren<{}>) {
|
|||||||
// We will need to confirm we handle nested navigators correctly by the time we migrate to React Navigation 8.x
|
// We will need to confirm we handle nested navigators correctly by the time we migrate to React Navigation 8.x
|
||||||
// -sfn
|
// -sfn
|
||||||
navigationInChildEnabled>
|
navigationInChildEnabled>
|
||||||
<AnalyticsContext
|
{children}
|
||||||
metadata={utils.useMeta({
|
|
||||||
navigation: {
|
|
||||||
previousScreen: prevLoggedRouteName.current,
|
|
||||||
currentScreen: getCurrentRouteName(),
|
|
||||||
},
|
|
||||||
})}>
|
|
||||||
{children}
|
|
||||||
</AnalyticsContext>
|
|
||||||
</NavigationContainer>
|
</NavigationContainer>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import {Onboarding} from '#/screens/Onboarding'
|
|||||||
import {SignupQueued} from '#/screens/SignupQueued'
|
import {SignupQueued} from '#/screens/SignupQueued'
|
||||||
import {atoms as a, useLayoutBreakpoints} from '#/alf'
|
import {atoms as a, useLayoutBreakpoints} from '#/alf'
|
||||||
import {PolicyUpdateOverlay} from '#/components/PolicyUpdateOverlay'
|
import {PolicyUpdateOverlay} from '#/components/PolicyUpdateOverlay'
|
||||||
|
import {AnalyticsContext, utils} from '#/analytics'
|
||||||
import {IS_NATIVE, IS_WEB} from '#/env'
|
import {IS_NATIVE, IS_WEB} from '#/env'
|
||||||
import {BottomBarWeb} from './bottom-bar/BottomBarWeb'
|
import {BottomBarWeb} from './bottom-bar/BottomBarWeb'
|
||||||
import {DesktopLeftNav} from './desktop/LeftNav'
|
import {DesktopLeftNav} from './desktop/LeftNav'
|
||||||
@@ -114,6 +115,11 @@ function NativeStackNavigator({
|
|||||||
const {setShowLoggedOut} = useLoggedOutViewControls()
|
const {setShowLoggedOut} = useLoggedOutViewControls()
|
||||||
const {isMobile} = useWebMediaQueries()
|
const {isMobile} = useWebMediaQueries()
|
||||||
const {leftNavMinimal} = useLayoutBreakpoints()
|
const {leftNavMinimal} = useLayoutBreakpoints()
|
||||||
|
const prevActiveRouteName = React.useRef<string | undefined>(undefined)
|
||||||
|
React.useEffect(() => {
|
||||||
|
prevActiveRouteName.current = activeRoute.name
|
||||||
|
}, [activeRoute.name])
|
||||||
|
|
||||||
if (!hasSession && (activeRouteRequiresAuth || IS_NATIVE)) {
|
if (!hasSession && (activeRouteRequiresAuth || IS_NATIVE)) {
|
||||||
return <LoggedOut />
|
return <LoggedOut />
|
||||||
}
|
}
|
||||||
@@ -148,24 +154,32 @@ function NativeStackNavigator({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<NavigationContent>
|
<NavigationContent>
|
||||||
<View role="main" style={a.flex_1}>
|
<AnalyticsContext
|
||||||
<NativeStackView
|
metadata={utils.useMeta({
|
||||||
{...rest}
|
navigation: {
|
||||||
state={state}
|
previousScreen: prevActiveRouteName.current,
|
||||||
navigation={navigation}
|
currentScreen: activeRoute.name,
|
||||||
descriptors={descriptors}
|
},
|
||||||
describe={describe}
|
})}>
|
||||||
/>
|
<View role="main" style={a.flex_1}>
|
||||||
</View>
|
<NativeStackView
|
||||||
{IS_WEB && (
|
{...rest}
|
||||||
<>
|
state={state}
|
||||||
{showBottomBar ? <BottomBarWeb /> : <DesktopLeftNav />}
|
navigation={navigation}
|
||||||
{!isMobile && <DesktopRightNav routeName={activeRoute.name} />}
|
descriptors={descriptors}
|
||||||
</>
|
describe={describe}
|
||||||
)}
|
/>
|
||||||
|
</View>
|
||||||
|
{IS_WEB && (
|
||||||
|
<>
|
||||||
|
{showBottomBar ? <BottomBarWeb /> : <DesktopLeftNav />}
|
||||||
|
{!isMobile && <DesktopRightNav routeName={activeRoute.name} />}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Only shown after logged in and onboaring etc are complete */}
|
{/* Only shown after logged in and onboaring etc are complete */}
|
||||||
{hasSession && <PolicyUpdateOverlay />}
|
{hasSession && <PolicyUpdateOverlay />}
|
||||||
|
</AnalyticsContext>
|
||||||
</NavigationContent>
|
</NavigationContent>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user