| ... | @@ -1,7 +1,7 @@ | ... | @@ -1,7 +1,7 @@ |
| 1 | import { useAuth } from "@clerk/expo"; | 1 | import { useAuth } from "@clerk/expo"; |
| 2 | import { AuthView, UserProfileView } from "@clerk/expo/native"; | 2 | import { AuthView, UserProfileView } from "@clerk/expo/native"; |
| 3 | import { StackActions, useNavigation } from "@react-navigation/native"; | 3 | import { StackActions, useNavigation } from "@react-navigation/native"; |
| 4 | import { useCallback, useLayoutEffect } from "react"; | 4 | import { useCallback, useEffect, useLayoutEffect, useRef } from "react"; |
| 5 | import { View } from "react-native"; | 5 | import { View } from "react-native"; |
| 6 | | 6 | |
| 7 | import { hasCloudPublicConfig } from "../cloud/publicConfig"; | 7 | import { hasCloudPublicConfig } from "../cloud/publicConfig"; |
| ... | @@ -25,11 +25,21 @@ function ConfiguredSettingsAuthRouteScreen() { | ... | @@ -25,11 +25,21 @@ function ConfiguredSettingsAuthRouteScreen() { |
| 25 | () => navigation.dispatch(StackActions.popTo("SettingsContent")), | 25 | () => navigation.dispatch(StackActions.popTo("SettingsContent")), |
| 26 | [navigation], | 26 | [navigation], |
| 27 | ); | 27 | ); |
| | 28 | const hasBeenSignedIn = useRef(isSignedIn); |
| | 29 | if (isSignedIn) { |
| | 30 | hasBeenSignedIn.current = true; |
| | 31 | } |
| | 32 | |
| | 33 | useEffect(() => { |
| | 34 | if (hasBeenSignedIn.current && isLoaded && isSignedIn === false) { |
| | 35 | navigation.dispatch(StackActions.popTo("SettingsContent")); |
| | 36 | } |
| | 37 | }, [isLoaded, isSignedIn, navigation]); |
| 28 | | 38 | |
| 29 | return ( | 39 | return ( |
| 30 | <View collapsable={false} className="flex-1 overflow-hidden bg-sheet"> | 40 | <View collapsable={false} className="flex-1 overflow-hidden bg-sheet"> |
| 31 | {isLoaded ? ( | 41 | {isLoaded ? ( |
| 32 | isSignedIn ? ( | 42 | hasBeenSignedIn.current ? ( |
| 33 | <UserProfileView isDismissible={false} onHostBack={handleHostBack} /> | 43 | <UserProfileView isDismissible={false} onHostBack={handleHostBack} /> |
| 34 | ) : ( | 44 | ) : ( |
| 35 | <AuthView isDismissible={false} onHostBack={handleHostBack} /> | 45 | <AuthView isDismissible={false} onHostBack={handleHostBack} /> |