diff options
Diffstat (limited to 'src/view/shell/index.tsx')
-rw-r--r-- | src/view/shell/index.tsx | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/src/view/shell/index.tsx b/src/view/shell/index.tsx index 703edf27a..5562af9ac 100644 --- a/src/view/shell/index.tsx +++ b/src/view/shell/index.tsx @@ -1,5 +1,4 @@ import React from 'react' -import {observer} from 'mobx-react-lite' import {StatusBar} from 'expo-status-bar' import { DimensionValue, @@ -11,7 +10,6 @@ import { import {useSafeAreaInsets} from 'react-native-safe-area-context' import {Drawer} from 'react-native-drawer-layout' import {useNavigationState} from '@react-navigation/native' -import {useStores} from 'state/index' import {ModalsContainer} from 'view/com/modals/Modal' import {Lightbox} from 'view/com/lightbox/Lightbox' import {ErrorBoundary} from 'view/com/util/ErrorBoundary' @@ -25,20 +23,19 @@ import { SafeAreaProvider, initialWindowMetrics, } from 'react-native-safe-area-context' -import {useOTAUpdate} from 'lib/hooks/useOTAUpdate' import { useIsDrawerOpen, useSetDrawerOpen, useIsDrawerSwipeDisabled, } from '#/state/shell' import {isAndroid} from 'platform/detection' +import {useSession} from '#/state/session' +import {useCloseAnyActiveElement} from '#/state/util' -const ShellInner = observer(function ShellInnerImpl() { - const store = useStores() +function ShellInner() { const isDrawerOpen = useIsDrawerOpen() const isDrawerSwipeDisabled = useIsDrawerSwipeDisabled() const setIsDrawerOpen = useSetDrawerOpen() - useOTAUpdate() // this hook polls for OTA updates every few seconds const winDim = useWindowDimensions() const safeAreaInsets = useSafeAreaInsets() const containerPadding = React.useMemo( @@ -55,18 +52,20 @@ const ShellInner = observer(function ShellInnerImpl() { [setIsDrawerOpen], ) const canGoBack = useNavigationState(state => !isStateAtTabRoot(state)) + const {hasSession} = useSession() + const closeAnyActiveElement = useCloseAnyActiveElement() + React.useEffect(() => { let listener = {remove() {}} if (isAndroid) { listener = BackHandler.addEventListener('hardwareBackPress', () => { - setIsDrawerOpen(false) - return store.shell.closeAnyActiveElement() + return closeAnyActiveElement() }) } return () => { listener.remove() } - }, [store, setIsDrawerOpen]) + }, [closeAnyActiveElement]) return ( <> @@ -78,28 +77,19 @@ const ShellInner = observer(function ShellInnerImpl() { onOpen={onOpenDrawer} onClose={onCloseDrawer} swipeEdgeWidth={winDim.width / 2} - swipeEnabled={ - !canGoBack && store.session.hasSession && !isDrawerSwipeDisabled - }> + swipeEnabled={!canGoBack && hasSession && !isDrawerSwipeDisabled}> <TabsNavigator /> </Drawer> </ErrorBoundary> </View> - <Composer - active={store.shell.isComposerActive} - winHeight={winDim.height} - replyTo={store.shell.composerOpts?.replyTo} - onPost={store.shell.composerOpts?.onPost} - quote={store.shell.composerOpts?.quote} - mention={store.shell.composerOpts?.mention} - /> + <Composer winHeight={winDim.height} /> <ModalsContainer /> <Lightbox /> </> ) -}) +} -export const Shell: React.FC = observer(function ShellImpl() { +export const Shell: React.FC = function ShellImpl() { const pal = usePalette('default') const theme = useTheme() return ( @@ -112,7 +102,7 @@ export const Shell: React.FC = observer(function ShellImpl() { </View> </SafeAreaProvider> ) -}) +} const styles = StyleSheet.create({ outerContainer: { |