Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions app/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ function AuthGate({ children }: { children: React.ReactNode }) {
const { isSignedIn, isLoaded } = useAuth();
const segments = useSegments();
const router = useRouter();
const onAuthScreen =
segments[0] === "sign-in" || segments[0] === "sign-up" || segments[0] === "landing";
const onAuthScreen = segments[0] === "auth";
const onPublicScreen = onAuthScreen || segments[0] === "shares";
// cli-auth manages its own signed-in/out states — never auto-redirect it.
const onCliAuth = segments[0] === "cli-auth";
Expand All @@ -24,7 +23,7 @@ function AuthGate({ children }: { children: React.ReactNode }) {
if (isSignedIn && onAuthScreen) {
router.replace("/");
} else if (!isSignedIn && !LOCAL_MODE && !onPublicScreen) {
router.replace("/landing");
router.replace("/auth");
}
}, [isSignedIn, isLoaded, onAuthScreen, onPublicScreen, onCliAuth, router]);

Expand All @@ -45,20 +44,12 @@ export default function RootLayout() {
<StatusBar style={colorScheme === "dark" ? "light" : "dark"} />
<Stack>
<Stack.Screen name="(main)" options={{ headerShown: false }} />
<Stack.Screen name="landing" options={{ headerShown: false }} />
<Stack.Screen name="auth" options={{ headerShown: false }} />
<Stack.Screen
name="shares/invite/[ownerUserId]/[token]/accept"
options={{ headerShown: false }}
/>
<Stack.Screen name="cli-auth" options={{ headerShown: false }} />
<Stack.Screen
name="sign-in"
options={{ headerShown: false, presentation: "modal" }}
/>
<Stack.Screen
name="sign-up"
options={{ headerShown: false, presentation: "modal" }}
/>
</Stack>
</AuthGate>
</AuthProvider>
Expand Down
Loading