Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok committed May 24, 2024
1 parent d5bf2da commit d15d4b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/lib/routes/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {NavigationProp} from '@react-navigation/native'
import {State, RouteParams} from './types'

import {RouteParams, State} from './types'

export function getRootNavigation<T extends {}>(
nav: NavigationProp<T>,
Expand All @@ -10,7 +11,11 @@ export function getRootNavigation<T extends {}>(
return nav
}

export function getCurrentRoute(state: State) {
export function getCurrentRoute(state?: State) {
if (!state) {
return {name: ''}
}

let node = state.routes[state.index || 0]
while (node.state?.routes && typeof node.state?.index === 'number') {
node = node.state?.routes[node.state?.index]
Expand Down
5 changes: 3 additions & 2 deletions src/view/com/feeds/FeedPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {View} from 'react-native'
import {AppBskyActorDefs} from '@atproto/api'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {useNavigation} from '@react-navigation/native'
import {NavigationProp, useNavigation} from '@react-navigation/native'
import {useQueryClient} from '@tanstack/react-query'

import {getRootNavigation, getTabState, TabState} from '#/lib/routes/helpers'
Expand All @@ -19,6 +19,7 @@ import {useSetMinimalShellMode} from '#/state/shell'
import {useComposerControls} from '#/state/shell/composer'
import {useAnalytics} from 'lib/analytics/analytics'
import {ComposeIcon2} from 'lib/icons'
import {AllNavigatorParams} from 'lib/routes/types'
import {s} from 'lib/styles'
import {useHeaderOffset} from '#/components/hooks/useHeaderOffset'
import {Feed} from '../posts/Feed'
Expand Down Expand Up @@ -48,7 +49,7 @@ export function FeedPage({
}) {
const {hasSession} = useSession()
const {_} = useLingui()
const navigation = useNavigation()
const navigation = useNavigation<NavigationProp<AllNavigatorParams>>()
const queryClient = useQueryClient()
const {openComposer} = useComposerControls()
const [isScrolledDown, setIsScrolledDown] = React.useState(false)
Expand Down

0 comments on commit d15d4b7

Please sign in to comment.