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, type SearchTabNavigatorParams,
} from '#/lib/routes/types' } from '#/lib/routes/types'
import {type RouteParams, type State} 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 {bskyTitle} from '#/lib/strings/headings'
import {logger} from '#/logger' import {logger} from '#/logger'
import {isNative, isWeb} from '#/platform/detection' import {isNative, isWeb} from '#/platform/detection'
@@ -149,7 +149,6 @@ import {useNonReactiveCallback} from './lib/hooks/useNonReactiveCallback'
import {useLoggedOutViewControls} from './state/shell/logged-out' import {useLoggedOutViewControls} from './state/shell/logged-out'
import {useLoggedOutView} from './state/shell/logged-out' import {useLoggedOutView} from './state/shell/logged-out'
import {useCloseAllActiveElements} from './state/util' import {useCloseAllActiveElements} from './state/util'
import {AuthModal} from './view/shell/desktop/AuthLayout'
const navigationRef = createNavigationContainerRef<AllNavigatorParams>() const navigationRef = createNavigationContainerRef<AllNavigatorParams>()
@@ -789,9 +788,11 @@ const FlatNavigator = () => {
*/ */
export const NativeNavigator = () => { export const NativeNavigator = () => {
const t = useTheme() const t = useTheme()
const gate = useGate()
const {hasSession} = useSession() const {hasSession} = useSession()
const {showLoggedOut} = useLoggedOutView() const {showLoggedOut} = useLoggedOutView()
if (gate('new_auth_flow')) {
return ( return (
<Core.Navigator screenOptions={screenOptions(t)}> <Core.Navigator screenOptions={screenOptions(t)}>
{hasSession && !showLoggedOut ? ( {hasSession && !showLoggedOut ? (
@@ -846,6 +847,9 @@ export const NativeNavigator = () => {
)} )}
</Core.Navigator> </Core.Navigator>
) )
} else {
return <TabsNavigator />
}
} }
/** /**
+1
View File
@@ -4,6 +4,7 @@ export type Gate =
| 'debug_show_feedcontext' | 'debug_show_feedcontext'
| 'debug_subscriptions' | 'debug_subscriptions'
| 'explore_show_suggested_feeds' | 'explore_show_suggested_feeds'
| 'new_auth_flow'
| 'old_postonboarding' | 'old_postonboarding'
| 'onboarding_add_video_feed' | 'onboarding_add_video_feed'
| 'post_threads_v2_unspecced' | 'post_threads_v2_unspecced'
@@ -27,6 +27,7 @@ import {
import {PWI_ENABLED} from '#/lib/build-flags' import {PWI_ENABLED} from '#/lib/build-flags'
import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries'
import {useGate} from '#/lib/statsig/statsig'
import {isWeb} from '#/platform/detection' import {isWeb} from '#/platform/detection'
import {useSession} from '#/state/session' import {useSession} from '#/state/session'
import {useOnboardingState} from '#/state/shell' import {useOnboardingState} from '#/state/shell'
@@ -34,6 +35,7 @@ import {
useLoggedOutView, useLoggedOutView,
useLoggedOutViewControls, useLoggedOutViewControls,
} from '#/state/shell/logged-out' } from '#/state/shell/logged-out'
import {LoggedOut} from '#/view/com/auth/LoggedOut'
import {AuthenticationFlow} from '#/screens/Authentication/components/Flow' import {AuthenticationFlow} from '#/screens/Authentication/components/Flow'
import {Deactivated} from '#/screens/Deactivated' import {Deactivated} from '#/screens/Deactivated'
import {Onboarding} from '#/screens/Onboarding' import {Onboarding} from '#/screens/Onboarding'
@@ -112,19 +114,33 @@ function NativeStackNavigator({
const {setShowLoggedOut} = useLoggedOutViewControls() const {setShowLoggedOut} = useLoggedOutViewControls()
const {isMobile} = useWebMediaQueries() const {isMobile} = useWebMediaQueries()
const {leftNavMinimal} = useLayoutBreakpoints() const {leftNavMinimal} = useLayoutBreakpoints()
// Temp: use old system for web. TODO: unify const gate = useGate()
if (isWeb && !hasSession && (!PWI_ENABLED || activeRouteRequiresAuth)) {
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 /> return <AuthenticationFlow />
} }
} else {
return <LoggedOut />
}
}
if (hasSession && currentAccount?.signupQueued) { if (hasSession && currentAccount?.signupQueued) {
return <SignupQueued /> return <SignupQueued />
} }
if (hasSession && currentAccount?.status === 'takendown') { if (hasSession && currentAccount?.status === 'takendown') {
return <Takendown /> return <Takendown />
} }
if (isWeb && showLoggedOut) { if (showLoggedOut) {
if (gate('new_auth_flow')) {
if (isWeb) {
return <AuthenticationFlow onDismiss={() => setShowLoggedOut(false)} /> return <AuthenticationFlow onDismiss={() => setShowLoggedOut(false)} />
} }
} else {
return <LoggedOut onDismiss={() => setShowLoggedOut(false)} />
}
}
if (currentAccount?.status === 'deactivated') { if (currentAccount?.status === 'deactivated') {
return <Deactivated /> return <Deactivated />
} }