Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

fix(mobile): prevent crash on sign out in settings (#4899)

shubhu277a7cb44582
diff --git a/apps/mobile/src/features/settings/SettingsAuthRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsAuthRouteScreen.tsx
index 5bc10af0a..96d612f8c 100644
--- a/apps/mobile/src/features/settings/SettingsAuthRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsAuthRouteScreen.tsx
@@ -1,7 +1,7 @@
import { useAuth } from "@clerk/expo";
import { AuthView, UserProfileView } from "@clerk/expo/native";
import { StackActions, useNavigation } from "@react-navigation/native";
-import { useCallback, useLayoutEffect } from "react";
+import { useCallback, useEffect, useLayoutEffect, useRef } from "react";
import { View } from "react-native";
import { hasCloudPublicConfig } from "../cloud/publicConfig";
@@ -25,11 +25,21 @@ function ConfiguredSettingsAuthRouteScreen() {
() => navigation.dispatch(StackActions.popTo("SettingsContent")),
[navigation],
);
+ const hasBeenSignedIn = useRef(isSignedIn);
+ if (isSignedIn) {
+ hasBeenSignedIn.current = true;
+ }
+
+ useEffect(() => {
+ if (hasBeenSignedIn.current && isLoaded && isSignedIn === false) {
+ navigation.dispatch(StackActions.popTo("SettingsContent"));
+ }
+ }, [isLoaded, isSignedIn, navigation]);
return (
<View collapsable={false} className="flex-1 overflow-hidden bg-sheet">
{isLoaded ? (
- isSignedIn ? (
+ hasBeenSignedIn.current ? (
<UserProfileView isDismissible={false} onHostBack={handleHostBack} />
) : (
<AuthView isDismissible={false} onHostBack={handleHostBack} />