2022-06-09 20:03:25 +02:00
|
|
|
import React, {useState, useEffect} from 'react'
|
2023-01-26 19:53:46 +01:00
|
|
|
import {SafeAreaProvider} from 'react-native-safe-area-context'
|
2023-02-23 22:52:12 +01:00
|
|
|
import {getInitialURL} from 'platform/urls'
|
2022-07-19 23:04:45 +02:00
|
|
|
import * as view from './view/index'
|
2022-07-19 22:37:24 +02:00
|
|
|
import {RootStoreModel, setupState, RootStoreProvider} from './state'
|
2023-01-26 19:53:46 +01:00
|
|
|
import {WebShell} from './view/shell/web'
|
2023-01-27 05:08:10 +01:00
|
|
|
import {ToastContainer} from './view/com/util/Toast.web'
|
2022-06-09 20:03:25 +02:00
|
|
|
|
|
|
|
function App() {
|
2022-07-19 22:37:24 +02:00
|
|
|
const [rootStore, setRootStore] = useState<RootStoreModel | undefined>(
|
|
|
|
undefined,
|
|
|
|
)
|
2022-06-09 20:03:25 +02:00
|
|
|
|
|
|
|
// init
|
|
|
|
useEffect(() => {
|
2022-07-19 23:04:45 +02:00
|
|
|
view.setup()
|
2023-02-23 22:52:12 +01:00
|
|
|
setupState().then(store => {
|
|
|
|
setRootStore(store)
|
2023-02-25 00:47:53 +01:00
|
|
|
store.nav.bindWebNavigation()
|
2023-02-23 22:52:12 +01:00
|
|
|
getInitialURL().then(url => {
|
|
|
|
if (url) {
|
|
|
|
store.nav.handleLink(url)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
2022-06-09 20:03:25 +02:00
|
|
|
}, [])
|
|
|
|
|
|
|
|
// show nothing prior to init
|
|
|
|
if (!rootStore) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2022-07-26 06:08:24 +02:00
|
|
|
<RootStoreProvider value={rootStore}>
|
2023-01-26 19:53:46 +01:00
|
|
|
<SafeAreaProvider>
|
|
|
|
<WebShell />
|
|
|
|
</SafeAreaProvider>
|
2023-01-27 05:08:10 +01:00
|
|
|
<ToastContainer />
|
2022-07-26 06:08:24 +02:00
|
|
|
</RootStoreProvider>
|
2022-06-09 20:03:25 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default App
|