From f75acd190d835491f317fe5d6be6285e7b52d801 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Tue, 15 Jul 2025 14:55:01 +0300 Subject: [PATCH] attempt to gate --- src/Navigation.tsx | 102 +++++++++--------- src/lib/statsig/gates.ts | 1 + .../createNativeStackNavigatorWithAuth.tsx | 26 ++++- 3 files changed, 75 insertions(+), 54 deletions(-) diff --git a/src/Navigation.tsx b/src/Navigation.tsx index 64a2c819a7..1ed6ebb94e 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -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() @@ -789,63 +788,68 @@ const FlatNavigator = () => { */ export const NativeNavigator = () => { const t = useTheme() + const gate = useGate() const {hasSession} = useSession() const {showLoggedOut} = useLoggedOutView() - return ( - - {hasSession && !showLoggedOut ? ( - TabsNavigator} - options={{animation: 'fade', animationDuration: 200}} - /> - ) : ( - <> + if (gate('new_auth_flow')) { + return ( + + {hasSession && !showLoggedOut ? ( LandingScreen} + name="App" + getComponent={() => TabsNavigator} options={{animation: 'fade', animationDuration: 200}} /> - StarterPackLandingScreen} - /> - + ) : ( + <> SelectAccountScreen} - /> - SignInScreen} /> - ForgotPasswordScreen} + name="Landing" + getComponent={() => LandingScreen} + options={{animation: 'fade', animationDuration: 200}} /> SetNewPasswordScreen} + name="StarterPackLanding" + getComponent={() => StarterPackLandingScreen} /> - PasswordUpdatedScreen} - /> - SignUpInfoScreen} - /> - SignUpHandleScreen} - /> - SignUpCaptchaScreen} - /> - - - )} - - ) + + SelectAccountScreen} + /> + SignInScreen} /> + ForgotPasswordScreen} + /> + SetNewPasswordScreen} + /> + PasswordUpdatedScreen} + /> + SignUpInfoScreen} + /> + SignUpHandleScreen} + /> + SignUpCaptchaScreen} + /> + + + )} + + ) + } else { + return + } } /** diff --git a/src/lib/statsig/gates.ts b/src/lib/statsig/gates.ts index 3b1106480d..2923f28e16 100644 --- a/src/lib/statsig/gates.ts +++ b/src/lib/statsig/gates.ts @@ -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' diff --git a/src/view/shell/createNativeStackNavigatorWithAuth.tsx b/src/view/shell/createNativeStackNavigatorWithAuth.tsx index 79fdd5df5f..6ddc689359 100644 --- a/src/view/shell/createNativeStackNavigatorWithAuth.tsx +++ b/src/view/shell/createNativeStackNavigatorWithAuth.tsx @@ -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,9 +114,17 @@ 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)) { - return + 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 + } + } else { + return + } } if (hasSession && currentAccount?.signupQueued) { return @@ -122,8 +132,14 @@ function NativeStackNavigator({ if (hasSession && currentAccount?.status === 'takendown') { return } - if (isWeb && showLoggedOut) { - return setShowLoggedOut(false)} /> + if (showLoggedOut) { + if (gate('new_auth_flow')) { + if (isWeb) { + return setShowLoggedOut(false)} /> + } + } else { + return setShowLoggedOut(false)} /> + } } if (currentAccount?.status === 'deactivated') { return