Browse Source

showing warning when there is no internet connection

master
analuizaff 3 years ago
parent
commit
ff2c0bcd57
  1. 14
      src/App.js

14
src/App.js

@ -15,25 +15,28 @@ 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 (
<AppLoading startAsync={restoreUser} onFinish={() => setIsReady(true)} />
);
} else if (netInfo.isInternetReachable) {
global.userDataBase = openDatabase();
initDatabase(global.userDataBase);
global.formsSockets = useFiltering(global.location);
@ -57,4 +60,5 @@ export default function App() {
</CurrentLocationProvider>
</AuthContext.Provider>
);
} else return <NoInternetConnectionScreen />;
}
Loading…
Cancel
Save