diff options
Diffstat (limited to 'apps/mobile/app/dashboard')
| -rw-r--r-- | apps/mobile/app/dashboard/(tabs)/settings.tsx | 22 | ||||
| -rw-r--r-- | apps/mobile/app/dashboard/_layout.tsx | 12 |
2 files changed, 17 insertions, 17 deletions
diff --git a/apps/mobile/app/dashboard/(tabs)/settings.tsx b/apps/mobile/app/dashboard/(tabs)/settings.tsx index fe138f52..f60c2495 100644 --- a/apps/mobile/app/dashboard/(tabs)/settings.tsx +++ b/apps/mobile/app/dashboard/(tabs)/settings.tsx @@ -1,29 +1,17 @@ -import { useEffect } from "react"; import { SafeAreaView, Text, View } from "react-native"; -import { useRouter } from "expo-router"; import { Button } from "@/components/ui/Button"; +import PageTitle from "@/components/ui/PageTitle"; import { useSession } from "@/lib/session"; import { api } from "@/lib/trpc"; -import PageTitle from "@/components/ui/PageTitle"; export default function Dashboard() { - const router = useRouter(); - - const { isLoggedIn, logout } = useSession(); - - useEffect(() => { - if (isLoggedIn !== undefined && !isLoggedIn) { - router.replace("signin"); - } - }, [isLoggedIn]); + const { logout } = useSession(); const { data, error, isLoading } = api.users.whoami.useQuery(); - useEffect(() => { - if (error?.data?.code === "UNAUTHORIZED") { - logout(); - } - }, [error]); + if (error?.data?.code === "UNAUTHORIZED") { + logout(); + } return ( <SafeAreaView> diff --git a/apps/mobile/app/dashboard/_layout.tsx b/apps/mobile/app/dashboard/_layout.tsx index bb14a203..ef04fcd1 100644 --- a/apps/mobile/app/dashboard/_layout.tsx +++ b/apps/mobile/app/dashboard/_layout.tsx @@ -1,6 +1,18 @@ +import { useIsLoggedIn } from "@/lib/session"; +import { useRouter } from "expo-router"; import { Stack } from "expo-router/stack"; +import { useEffect } from "react"; export default function Dashboard() { + const router = useRouter(); + + const isLoggedIn = useIsLoggedIn(); + useEffect(() => { + if (isLoggedIn !== undefined && !isLoggedIn) { + return router.replace("signin"); + } + }, [isLoggedIn]); + return ( <Stack> <Stack.Screen |
