refactor(mobile): improve dev experience in login page (#2902)

This commit is contained in:
Whitewater
2025-02-27 15:23:41 +08:00
committed by GitHub
parent 90ba67acac
commit 59db5a8de5
+25 -4
View File
@@ -1,4 +1,5 @@
import { Redirect } from "expo-router"
import { Redirect, router } from "expo-router"
import { Text, TouchableOpacity } from "react-native"
import { Login } from "@/src/modules/login"
import { useWhoami } from "@/src/store/user/hooks"
@@ -6,9 +7,29 @@ import { useWhoami } from "@/src/store/user/hooks"
export default function LoginPage() {
const whoami = useWhoami()
if (whoami?.id && !__DEV__) {
return <Redirect href="/" />
if (!whoami?.id) {
// Not logged in
return <Login />
}
// For development purposes, we don't want to redirect to the home page automatically
if (__DEV__) {
return (
<>
<Login />
<TouchableOpacity
className="bg-system-fill absolute bottom-8 left-1/2 -translate-x-1/2 flex-row items-center justify-center rounded-xl p-2 px-4"
activeOpacity={0.7}
onPress={() => {
router.replace("/")
}}
>
<Text className="text-secondary-label text-center font-semibold">
Redirect to Home (DEV)
</Text>
</TouchableOpacity>
</>
)
}
return <Login />
return <Redirect href="/" />
}