From 5c7fb61c352057ffe01a46c5210eb389eacdb50c Mon Sep 17 00:00:00 2001 From: Joselito Lima Date: Mon, 29 Jan 2024 20:07:36 -0300 Subject: [PATCH] fix isReady location verification --- src/App.js | 60 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/src/App.js b/src/App.js index 26b92f1..ddd2d6f 100644 --- a/src/App.js +++ b/src/App.js @@ -26,9 +26,6 @@ import { connect } from "formik"; import colors from "./app/config/colors"; import { dimensions } from "./app/config/dimensions"; - -SplashScreen.preventAutoHideAsync(); - export default function App() { const [user, setUser] = useState(); const [pluviometerStation, setPluviometerStation] = useState(undefined); @@ -107,38 +104,49 @@ export default function App() { }, [pluviometerStation]); useEffect(()=>{ + const restoreUser = async () => { + await SplashScreen.preventAutoHideAsync(); + const storageUser = await authStorage.getUser(); if (storageUser) setUser(storageUser); - global.location = await getLocation(); - SplashScreen.hideAsync(); + setIsReady(true) + await SplashScreen.hideAsync(); }; restoreUser() - }) + },[]) + + + if(!isReady) { + + return null - if (global.formsSockets === undefined) + } else { + + if (global.formsSockets === undefined) global.formsSockets = useFiltering( global.location || global.defaultLocation ); - return ( - - - - - - {user ? : } - - - - - - - ); + return ( + + + + + + {user ? : } + + + + + + + ); + } }