diff --git a/apps/mobile/app/dashboard/_layout.tsx b/apps/mobile/app/dashboard/_layout.tsx index f1bb66d7..c9f7355b 100644 --- a/apps/mobile/app/dashboard/_layout.tsx +++ b/apps/mobile/app/dashboard/_layout.tsx @@ -1,7 +1,16 @@ +import type { AppStateStatus } from "react-native"; import { useEffect } from "react"; +import { AppState, Platform } from "react-native"; import { useRouter } from "expo-router"; import { Stack } from "expo-router/stack"; import { useIsLoggedIn } from "@/lib/session"; +import { focusManager } from "@tanstack/react-query"; + +function onAppStateChange(status: AppStateStatus) { + if (Platform.OS !== "web") { + focusManager.setFocused(status === "active"); + } +} export default function Dashboard() { const router = useRouter(); @@ -13,6 +22,12 @@ export default function Dashboard() { } }, [isLoggedIn]); + useEffect(() => { + const subscription = AppState.addEventListener("change", onAppStateChange); + + return () => subscription.remove(); + }, []); + return (