aboutsummaryrefslogtreecommitdiffstats
path: root/packages/mobile/app/index.tsx
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-03-11 14:36:04 +0000
committerMohamedBassem <me@mbassem.com>2024-03-11 14:36:47 +0000
commite1c511c7c27034f94b8598b44467782af346b9c1 (patch)
tree3b75e0277e3c795d6f03a60007363e54ad73e2ac /packages/mobile/app/index.tsx
parentb3f081b300125cfe43af38001fee392083a4b880 (diff)
downloadkarakeep-e1c511c7c27034f94b8598b44467782af346b9c1.tar.zst
mobile: Do the session routing in the homescreen
Diffstat (limited to 'packages/mobile/app/index.tsx')
-rw-r--r--packages/mobile/app/index.tsx23
1 files changed, 16 insertions, 7 deletions
diff --git a/packages/mobile/app/index.tsx b/packages/mobile/app/index.tsx
index 557417d7..5ce20cda 100644
--- a/packages/mobile/app/index.tsx
+++ b/packages/mobile/app/index.tsx
@@ -1,11 +1,20 @@
-import { Link } from "expo-router";
+import { useRouter } from "expo-router";
+import { useEffect } from "react";
import { View } from "react-native";
+import { useSession } from "@/lib/session";
+
export default function App() {
- return (
- <View className="flex-1 items-center justify-center gap-4 bg-white">
- <Link href="signin">Signin</Link>
- <Link href="dashboard">Dashboard</Link>
- </View>
- );
+ const router = useRouter();
+ const { isLoggedIn } = useSession();
+ useEffect(() => {
+ if (isLoggedIn === undefined) {
+ // Wait until it's loaded
+ } else if (isLoggedIn) {
+ router.replace("dashboard");
+ } else {
+ router.replace("signin");
+ }
+ }, [isLoggedIn]);
+ return <View />;
}