diff options
Diffstat (limited to 'src/App.native.tsx')
-rw-r--r-- | src/App.native.tsx | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/src/App.native.tsx b/src/App.native.tsx index f00e3cad1..17b8b4552 100644 --- a/src/App.native.tsx +++ b/src/App.native.tsx @@ -6,35 +6,27 @@ import {GestureHandlerRootView} from 'react-native-gesture-handler' import SplashScreen from 'react-native-splash-screen' import {SafeAreaProvider} from 'react-native-safe-area-context' import {observer} from 'mobx-react-lite' -import { - createClient, - SegmentClient, - AnalyticsProvider, -} from '@segment/analytics-react-native' -import {ThemeProvider} from './view/lib/ThemeContext' +import {ThemeProvider} from 'lib/ThemeContext' import * as view from './view/index' import {RootStoreModel, setupState, RootStoreProvider} from './state' import {MobileShell} from './view/shell/mobile' -import {s} from './view/lib/styles' -import notifee, {EventType} from '@notifee/react-native' +import {s} from 'lib/styles' +import * as notifee from 'lib/notifee' +import * as analytics from 'lib/analytics' +import * as Toast from './view/com/util/Toast' const App = observer(() => { const [rootStore, setRootStore] = useState<RootStoreModel | undefined>( undefined, ) - const [segment, setSegment] = useState<SegmentClient | undefined>(undefined) // init useEffect(() => { view.setup() - setSegment( - createClient({ - writeKey: '8I6DsgfiSLuoONyaunGoiQM7A6y2ybdI', - trackAppLifecycleEvents: true, - }), - ) setupState().then(store => { setRootStore(store) + analytics.init(store) + notifee.init(store) SplashScreen.hide() Linking.getInitialURL().then((url: string | null) => { if (url) { @@ -44,12 +36,8 @@ const App = observer(() => { Linking.addEventListener('url', ({url}) => { store.nav.handleLink(url) }) - notifee.onForegroundEvent(async ({type}: {type: EventType}) => { - store.log.debug('Notifee foreground event', {type}) - if (type === EventType.PRESS) { - store.log.debug('User pressed a notifee, opening notifications') - store.nav.switchTo(1, true) - } + store.onSessionDropped(() => { + Toast.show('Sorry! Your session expired. Please log in again.') }) }) }, []) @@ -58,20 +46,19 @@ const App = observer(() => { if (!rootStore) { return null } - return ( <GestureHandlerRootView style={s.h100pct}> - <RootSiblingParent> - <AnalyticsProvider client={segment}> - <RootStoreProvider value={rootStore}> - <ThemeProvider theme={rootStore.shell.darkMode ? 'dark' : 'light'}> + <ThemeProvider theme={rootStore.shell.darkMode ? 'dark' : 'light'}> + <RootSiblingParent> + <analytics.Provider> + <RootStoreProvider value={rootStore}> <SafeAreaProvider> <MobileShell /> </SafeAreaProvider> - </ThemeProvider> - </RootStoreProvider> - </AnalyticsProvider> - </RootSiblingParent> + </RootStoreProvider> + </analytics.Provider> + </RootSiblingParent> + </ThemeProvider> </GestureHandlerRootView> ) }) |