|
@ -4,6 +4,7 @@ import { NavigationContainer } from "@react-navigation/native"; |
|
|
import navigationTheme from "./app/navigation/navigationTheme"; |
|
|
import navigationTheme from "./app/navigation/navigationTheme"; |
|
|
import "./app/config/globals.js"; |
|
|
import "./app/config/globals.js"; |
|
|
import openDatabase from "./app/database/database-connection"; |
|
|
import openDatabase from "./app/database/database-connection"; |
|
|
|
|
|
import { AppLoading } from "expo"; |
|
|
|
|
|
|
|
|
import initDatabase from "./app/database/database-init"; |
|
|
import initDatabase from "./app/database/database-init"; |
|
|
import FlashMessage from "react-native-flash-message"; |
|
|
import FlashMessage from "react-native-flash-message"; |
|
@ -17,6 +18,7 @@ import jwtDecode from "jwt-decode"; |
|
|
|
|
|
|
|
|
export default function App() { |
|
|
export default function App() { |
|
|
const [user, setUser] = useState(); |
|
|
const [user, setUser] = useState(); |
|
|
|
|
|
const [isReady, setIsReady] = useState(); |
|
|
|
|
|
|
|
|
const restoreToken = async () => { |
|
|
const restoreToken = async () => { |
|
|
const token = await authStorage.getToken(); |
|
|
const token = await authStorage.getToken(); |
|
@ -25,9 +27,10 @@ export default function App() { |
|
|
return setUser(jwtDecode(token)); |
|
|
return setUser(jwtDecode(token)); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
restoreToken(); |
|
|
|
|
|
}, []); |
|
|
|
|
|
|
|
|
if (!isReady) |
|
|
|
|
|
return ( |
|
|
|
|
|
<AppLoading startAsync={restoreToken} onFinish={() => setIsReady(true)} /> |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
global.userDataBase = openDatabase(); |
|
|
global.userDataBase = openDatabase(); |
|
|
initDatabase(global.userDataBase); |
|
|
initDatabase(global.userDataBase); |
|
|