2022-06-09 20:03:25 +02:00
|
|
|
import React, {useState, useEffect} from 'react'
|
2023-05-01 21:42:31 +02:00
|
|
|
import 'lib/sentry' // must be relatively on top
|
2023-01-26 19:53:46 +01:00
|
|
|
import {SafeAreaProvider} from 'react-native-safe-area-context'
|
2023-03-13 22:01:43 +01:00
|
|
|
import {RootSiblingParent} from 'react-native-root-siblings'
|
2022-07-19 23:04:45 +02:00
|
|
|
import * as view from './view/index'
|
2023-06-15 23:45:14 +02:00
|
|
|
import * as analytics from 'lib/analytics/analytics'
|
2022-07-19 22:37:24 +02:00
|
|
|
import {RootStoreModel, setupState, RootStoreProvider} from './state'
|
2023-03-13 22:01:43 +01:00
|
|
|
import {Shell} from './view/shell/index'
|
2023-01-27 05:08:10 +01:00
|
|
|
import {ToastContainer} from './view/com/util/Toast.web'
|
2023-04-13 03:49:40 +02:00
|
|
|
import {ThemeProvider} from 'lib/ThemeContext'
|
|
|
|
import {observer} from 'mobx-react-lite'
|
2022-06-09 20:03:25 +02:00
|
|
|
|
2023-09-08 02:36:08 +02:00
|
|
|
const App = observer(function AppImpl() {
|
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-04-04 20:01:38 +02:00
|
|
|
analytics.init(store)
|
2023-02-23 22:52:12 +01:00
|
|
|
})
|
2022-06-09 20:03:25 +02:00
|
|
|
}, [])
|
|
|
|
|
|
|
|
// show nothing prior to init
|
|
|
|
if (!rootStore) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2023-05-17 06:36:43 +02:00
|
|
|
<ThemeProvider theme={rootStore.shell.colorMode}>
|
2023-04-13 03:49:40 +02:00
|
|
|
<RootSiblingParent>
|
|
|
|
<analytics.Provider>
|
|
|
|
<RootStoreProvider value={rootStore}>
|
|
|
|
<SafeAreaProvider>
|
|
|
|
<Shell />
|
|
|
|
</SafeAreaProvider>
|
|
|
|
<ToastContainer />
|
|
|
|
</RootStoreProvider>
|
|
|
|
</analytics.Provider>
|
|
|
|
</RootSiblingParent>
|
|
|
|
</ThemeProvider>
|
2022-06-09 20:03:25 +02:00
|
|
|
)
|
2023-04-13 03:49:40 +02:00
|
|
|
})
|
2022-06-09 20:03:25 +02:00
|
|
|
|
|
|
|
export default App
|