2021-01-13 01:03:46 +01:00
|
|
|
import { ActionSheetProvider } from '@expo/react-native-action-sheet'
|
2022-12-05 13:40:36 +01:00
|
|
|
import getLanguage from '@helpers/getLanguage'
|
2021-05-12 15:40:55 +02:00
|
|
|
import queryClient from '@helpers/queryClient'
|
2021-01-27 00:35:34 +01:00
|
|
|
import i18n from '@root/i18n/i18n'
|
2021-02-08 23:19:55 +01:00
|
|
|
import Screens from '@root/Screens'
|
2021-01-27 00:35:34 +01:00
|
|
|
import audio from '@root/startup/audio'
|
2021-01-13 01:03:46 +01:00
|
|
|
import dev from '@root/startup/dev'
|
|
|
|
import log from '@root/startup/log'
|
|
|
|
import netInfo from '@root/startup/netInfo'
|
2022-05-08 17:56:26 +02:00
|
|
|
import push from '@root/startup/push'
|
2021-01-27 00:35:34 +01:00
|
|
|
import sentry from '@root/startup/sentry'
|
2022-05-08 17:56:26 +02:00
|
|
|
import timezone from '@root/startup/timezone'
|
2020-12-27 18:43:49 +01:00
|
|
|
import { persistor, store } from '@root/store'
|
2022-09-24 13:42:15 +02:00
|
|
|
import * as Sentry from '@sentry/react-native'
|
2021-03-27 00:02:32 +01:00
|
|
|
import AccessibilityManager from '@utils/accessibility/AccessibilityManager'
|
2022-12-05 13:40:36 +01:00
|
|
|
import { changeLanguage } from '@utils/slices/settingsSlice'
|
2020-12-27 18:43:49 +01:00
|
|
|
import ThemeManager from '@utils/styles/ThemeManager'
|
2022-10-11 22:28:59 +02:00
|
|
|
import * as Localization from 'expo-localization'
|
2020-12-13 22:31:55 +01:00
|
|
|
import * as SplashScreen from 'expo-splash-screen'
|
2020-12-22 00:50:47 +01:00
|
|
|
import React, { useCallback, useEffect, useState } from 'react'
|
2022-12-03 21:56:52 +01:00
|
|
|
import { IntlProvider } from 'react-intl'
|
2022-06-03 21:25:20 +02:00
|
|
|
import { LogBox, Platform } from 'react-native'
|
2021-12-18 12:06:35 +01:00
|
|
|
import { GestureHandlerRootView } from 'react-native-gesture-handler'
|
2022-11-20 16:14:08 +01:00
|
|
|
import { SafeAreaProvider } from 'react-native-safe-area-context'
|
2021-12-18 19:59:38 +01:00
|
|
|
import { enableFreeze } from 'react-native-screens'
|
2022-12-10 14:47:19 +01:00
|
|
|
import { QueryClientProvider } from '@tanstack/react-query'
|
2020-11-21 13:19:05 +01:00
|
|
|
import { Provider } from 'react-redux'
|
2020-11-29 13:11:23 +01:00
|
|
|
import { PersistGate } from 'redux-persist/integration/react'
|
2021-01-13 01:03:46 +01:00
|
|
|
|
2021-02-27 16:33:54 +01:00
|
|
|
Platform.select({
|
|
|
|
android: LogBox.ignoreLogs(['Setting a timer for a long period of time'])
|
|
|
|
})
|
2020-11-04 22:26:38 +01:00
|
|
|
|
2021-01-07 19:13:09 +01:00
|
|
|
dev()
|
2021-01-23 02:41:50 +01:00
|
|
|
sentry()
|
2021-01-07 19:13:09 +01:00
|
|
|
audio()
|
2021-02-27 16:33:54 +01:00
|
|
|
push()
|
2022-05-08 17:56:26 +02:00
|
|
|
timezone()
|
2022-02-02 22:47:30 +01:00
|
|
|
enableFreeze(true)
|
2020-12-27 18:43:49 +01:00
|
|
|
|
2020-11-23 00:07:32 +01:00
|
|
|
const App: React.FC = () => {
|
2021-01-07 19:13:09 +01:00
|
|
|
log('log', 'App', 'rendering App')
|
2021-01-03 02:00:26 +01:00
|
|
|
const [localCorrupt, setLocalCorrupt] = useState<string>()
|
2020-12-28 23:20:18 +01:00
|
|
|
|
2020-12-13 22:31:55 +01:00
|
|
|
useEffect(() => {
|
|
|
|
const delaySplash = async () => {
|
2021-01-07 19:13:09 +01:00
|
|
|
log('log', 'App', 'delay splash')
|
2020-12-13 22:31:55 +01:00
|
|
|
try {
|
|
|
|
await SplashScreen.preventAutoHideAsync()
|
|
|
|
} catch (e) {
|
|
|
|
console.warn(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delaySplash()
|
|
|
|
}, [])
|
2021-01-07 19:13:09 +01:00
|
|
|
|
|
|
|
const onBeforeLift = useCallback(async () => {
|
2021-01-10 02:12:14 +01:00
|
|
|
let netInfoRes = undefined
|
|
|
|
try {
|
|
|
|
netInfoRes = await netInfo()
|
|
|
|
} catch {}
|
2021-01-07 19:13:09 +01:00
|
|
|
|
2021-01-10 02:12:14 +01:00
|
|
|
if (netInfoRes && netInfoRes.corrupted && netInfoRes.corrupted.length) {
|
2021-01-07 19:13:09 +01:00
|
|
|
setLocalCorrupt(netInfoRes.corrupted)
|
2020-12-13 22:31:55 +01:00
|
|
|
}
|
|
|
|
|
2021-01-07 19:13:09 +01:00
|
|
|
log('log', 'App', 'hide splash')
|
|
|
|
try {
|
|
|
|
await SplashScreen.hideAsync()
|
|
|
|
return Promise.resolve()
|
|
|
|
} catch (e) {
|
|
|
|
console.warn(e)
|
|
|
|
return Promise.reject()
|
|
|
|
}
|
2020-12-28 23:20:18 +01:00
|
|
|
}, [])
|
2020-12-22 00:50:47 +01:00
|
|
|
|
2020-11-23 00:07:32 +01:00
|
|
|
return (
|
2021-12-18 12:06:35 +01:00
|
|
|
<GestureHandlerRootView style={{ flex: 1 }}>
|
|
|
|
<QueryClientProvider client={queryClient}>
|
|
|
|
<Provider store={store}>
|
|
|
|
<PersistGate
|
|
|
|
persistor={persistor}
|
|
|
|
onBeforeLift={onBeforeLift}
|
2022-08-07 01:18:10 +02:00
|
|
|
children={bootstrapped => {
|
|
|
|
log('log', 'App', 'bootstrapped')
|
|
|
|
if (bootstrapped) {
|
|
|
|
log('log', 'App', 'loading actual app :)')
|
2022-10-11 22:28:59 +02:00
|
|
|
log('log', 'App', `Locale: ${Localization.locale}`)
|
2022-12-05 13:40:36 +01:00
|
|
|
const language = getLanguage()
|
2022-08-07 01:18:10 +02:00
|
|
|
if (!language) {
|
2022-10-11 22:28:59 +02:00
|
|
|
if (Platform.OS !== 'ios') {
|
|
|
|
store.dispatch(changeLanguage('en'))
|
|
|
|
}
|
2022-08-07 01:18:10 +02:00
|
|
|
i18n.changeLanguage('en')
|
|
|
|
} else {
|
|
|
|
i18n.changeLanguage(language)
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2022-12-03 21:56:52 +01:00
|
|
|
<IntlProvider locale={language}>
|
|
|
|
<SafeAreaProvider>
|
|
|
|
<ActionSheetProvider>
|
|
|
|
<AccessibilityManager>
|
|
|
|
<ThemeManager>
|
|
|
|
<Screens localCorrupt={localCorrupt} />
|
|
|
|
</ThemeManager>
|
|
|
|
</AccessibilityManager>
|
|
|
|
</ActionSheetProvider>
|
|
|
|
</SafeAreaProvider>
|
|
|
|
</IntlProvider>
|
2022-08-07 01:18:10 +02:00
|
|
|
)
|
|
|
|
} else {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
}}
|
2021-12-18 12:06:35 +01:00
|
|
|
/>
|
|
|
|
</Provider>
|
|
|
|
</QueryClientProvider>
|
|
|
|
</GestureHandlerRootView>
|
2020-11-23 00:07:32 +01:00
|
|
|
)
|
|
|
|
}
|
2020-10-31 21:04:46 +01:00
|
|
|
|
2022-09-24 13:42:15 +02:00
|
|
|
export default Sentry.wrap(App)
|