00d41c9168
* Add search tab and move icon to footer * Remove subtitles from view header * Remove unused code * Clean up UI of search screen * Search: give better user feedback to UI state and add a cancel button * Add WhoToFollow section to search * Add a temporary SuggestedPosts solution using the patented 'bsky team algo' * Trigger reload of suggested content in search on open * Wait five min between reloading discovery content * Reduce weight of solid search icon in footer * Fix lint * Fix tests
76 lines
2.5 KiB
TypeScript
76 lines
2.5 KiB
TypeScript
import 'react-native-url-polyfill/auto'
|
|
import React, {useState, useEffect} from 'react'
|
|
import {Linking} from 'react-native'
|
|
import {RootSiblingParent} from 'react-native-root-siblings'
|
|
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 {SegmentClient, AnalyticsProvider} from '@segment/analytics-react-native'
|
|
import {TabPurpose} from './state/models/navigation'
|
|
import {ThemeProvider} from './view/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 {segmentClient} from './lib/segmentClient'
|
|
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(segmentClient)
|
|
setupState().then(store => {
|
|
setRootStore(store)
|
|
SplashScreen.hide()
|
|
Linking.getInitialURL().then((url: string | null) => {
|
|
if (url) {
|
|
store.nav.handleLink(url)
|
|
}
|
|
})
|
|
Linking.addEventListener('url', ({url}) => {
|
|
store.nav.handleLink(url)
|
|
})
|
|
store.onSessionDropped(() => {
|
|
Toast.show('Sorry! Your session expired. Please log in again.')
|
|
})
|
|
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(TabPurpose.Notifs, true)
|
|
}
|
|
})
|
|
})
|
|
}, [])
|
|
|
|
// show nothing prior to init
|
|
if (!rootStore) {
|
|
return null
|
|
}
|
|
return (
|
|
<GestureHandlerRootView style={s.h100pct}>
|
|
<ThemeProvider theme={rootStore.shell.darkMode ? 'dark' : 'light'}>
|
|
<RootSiblingParent>
|
|
<AnalyticsProvider client={segment}>
|
|
<RootStoreProvider value={rootStore}>
|
|
<SafeAreaProvider>
|
|
<MobileShell />
|
|
</SafeAreaProvider>
|
|
</RootStoreProvider>
|
|
</AnalyticsProvider>
|
|
</RootSiblingParent>
|
|
</ThemeProvider>
|
|
</GestureHandlerRootView>
|
|
)
|
|
})
|
|
|
|
export default App
|