attempt to gate

This commit is contained in:
Samuel Newman
2025-07-15 14:55:01 +03:00
parent e5613c909c
commit f75acd190d
3 changed files with 75 additions and 54 deletions
+6 -2
View File
@@ -40,7 +40,7 @@ import {
type SearchTabNavigatorParams,
} from '#/lib/routes/types'
import {type RouteParams, type State} from '#/lib/routes/types'
import {attachRouteToLogEvents, logEvent} from '#/lib/statsig/statsig'
import {attachRouteToLogEvents, logEvent, useGate} from '#/lib/statsig/statsig'
import {bskyTitle} from '#/lib/strings/headings'
import {logger} from '#/logger'
import {isNative, isWeb} from '#/platform/detection'
@@ -149,7 +149,6 @@ import {useNonReactiveCallback} from './lib/hooks/useNonReactiveCallback'
import {useLoggedOutViewControls} from './state/shell/logged-out'
import {useLoggedOutView} from './state/shell/logged-out'
import {useCloseAllActiveElements} from './state/util'
import {AuthModal} from './view/shell/desktop/AuthLayout'
const navigationRef = createNavigationContainerRef<AllNavigatorParams>()
@@ -789,9 +788,11 @@ const FlatNavigator = () => {
*/
export const NativeNavigator = () => {
const t = useTheme()
const gate = useGate()
const {hasSession} = useSession()
const {showLoggedOut} = useLoggedOutView()
if (gate('new_auth_flow')) {
return (
<Core.Navigator screenOptions={screenOptions(t)}>
{hasSession && !showLoggedOut ? (
@@ -846,6 +847,9 @@ export const NativeNavigator = () => {
)}
</Core.Navigator>
)
} else {
return <TabsNavigator />
}
}
/**
+1
View File
@@ -4,6 +4,7 @@ export type Gate =
| 'debug_show_feedcontext'
| 'debug_subscriptions'
| 'explore_show_suggested_feeds'
| 'new_auth_flow'
| 'old_postonboarding'
| 'onboarding_add_video_feed'
| 'post_threads_v2_unspecced'
@@ -27,6 +27,7 @@ import {
import {PWI_ENABLED} from '#/lib/build-flags'
import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries'
import {useGate} from '#/lib/statsig/statsig'
import {isWeb} from '#/platform/detection'
import {useSession} from '#/state/session'
import {useOnboardingState} from '#/state/shell'
@@ -34,6 +35,7 @@ import {
useLoggedOutView,
useLoggedOutViewControls,
} from '#/state/shell/logged-out'
import {LoggedOut} from '#/view/com/auth/LoggedOut'
import {AuthenticationFlow} from '#/screens/Authentication/components/Flow'
import {Deactivated} from '#/screens/Deactivated'
import {Onboarding} from '#/screens/Onboarding'
@@ -112,19 +114,33 @@ function NativeStackNavigator({
const {setShowLoggedOut} = useLoggedOutViewControls()
const {isMobile} = useWebMediaQueries()
const {leftNavMinimal} = useLayoutBreakpoints()
// Temp: use old system for web. TODO: unify
if (isWeb && !hasSession && (!PWI_ENABLED || activeRouteRequiresAuth)) {
const gate = useGate()
if (!hasSession && (!PWI_ENABLED || activeRouteRequiresAuth)) {
if (gate('new_auth_flow')) {
// I don't like how we have to split it like this, would prefer something neater
if (isWeb) {
return <AuthenticationFlow />
}
} else {
return <LoggedOut />
}
}
if (hasSession && currentAccount?.signupQueued) {
return <SignupQueued />
}
if (hasSession && currentAccount?.status === 'takendown') {
return <Takendown />
}
if (isWeb && showLoggedOut) {
if (showLoggedOut) {
if (gate('new_auth_flow')) {
if (isWeb) {
return <AuthenticationFlow onDismiss={() => setShowLoggedOut(false)} />
}
} else {
return <LoggedOut onDismiss={() => setShowLoggedOut(false)} />
}
}
if (currentAccount?.status === 'deactivated') {
return <Deactivated />
}