Browse Source

Merge branch 'main' of github.com:IGSD-UoW/WPD-MobileApp

master
GabrielTrettel 3 years ago
parent
commit
047c2c9d13
  1. 12
      src/App.js

12
src/App.js

@ -17,23 +17,26 @@ import authStorage from "./app/auth/storage";
import MapDataProvider from "./app/context/MapDataContext";
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