From ff2c0bcd5746a8ae4f4b3cb83c13bc1185a9ccc6 Mon Sep 17 00:00:00 2001 From: analuizaff Date: Wed, 6 Oct 2021 19:50:25 -0300 Subject: [PATCH] showing warning when there is no internet connection --- src/App.js | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/App.js b/src/App.js index 44bc028..cb68000 100644 --- a/src/App.js +++ b/src/App.js @@ -15,46 +15,50 @@ import AuthNavigator from "./app/navigation/AuthNavigator"; import { AuthContext } from "./app/auth/context"; import authStorage from "./app/auth/storage"; import MapDataProvider from "./app/context/MapDataContext"; -import {getLocation} from "./app/hooks/useLocation"; +import { getLocation } from "./app/hooks/useLocation"; import { useFiltering } from "./app/hooks/useFiltering"; +import NoInternetConnectionScreen from "./app/screens/NoInternetConnectionScreen"; +import NetInfo, { useNetInfo } from "@react-native-community/netinfo"; export default function App() { const [user, setUser] = useState(); const [isReady, setIsReady] = useState(); - + + const netInfo = useNetInfo(); + const restoreUser = async () => { const user = await authStorage.getUser(); - global.location ={"lat":-10.0173780726763, - "long": -67.8170775249999} // await getLocation(); + global.location = { lat: -23.623, long: -46.5637 }; // await getLocation(); if (user) setUser(user); }; - if (!isReady) + if (!isReady && netInfo.isInternetReachable) { return ( setIsReady(true)} /> ); + } else if (netInfo.isInternetReachable) { + global.userDataBase = openDatabase(); + initDatabase(global.userDataBase); + global.formsSockets = useFiltering(global.location); - global.userDataBase = openDatabase(); - initDatabase(global.userDataBase); - global.formsSockets = useFiltering(global.location); - - return ( - - - + return ( + + + {user ? : } - - - - ); + + + + ); + } else return ; }