···99import {BSKY_DOWNLOAD_URL} from '#/lib/constants'
1010import {useNavigationDeduped} from '#/lib/hooks/useNavigationDeduped'
1111import {useOpenLink} from '#/lib/hooks/useOpenLink'
1212-import {type AllNavigatorParams} from '#/lib/routes/types'
1212+import {type AllNavigatorParams, type RouteParams} from '#/lib/routes/types'
1313import {shareUrl} from '#/lib/sharing'
1414import {
1515 convertBskyAppUrlIfNeeded,
···155155 } else {
156156 closeModal() // close any active modals
157157158158+ const [screen, params] = router.matchPath(href) as [
159159+ screen: keyof AllNavigatorParams,
160160+ params?: RouteParams,
161161+ ]
162162+163163+ // does not apply to web's flat navigator
164164+ if (isNative && screen !== 'NotFound') {
165165+ const state = navigation.getState()
166166+ // if screen is not in the current navigator, it means it's
167167+ // most likely a tab screen
168168+ if (!state.routeNames.includes(screen)) {
169169+ const parent = navigation.getParent()
170170+ if (
171171+ parent &&
172172+ parent.getState().routeNames.includes(`${screen}Tab`)
173173+ ) {
174174+ // yep, it's a tab screen. i.e. SearchTab
175175+ // thus we need to navigate to the child screen
176176+ // via the parent navigator
177177+ // see https://reactnavigation.org/docs/upgrading-from-6.x/#changes-to-the-navigate-action
178178+ // TODO: can we support the other kinds of actions? push/replace -sfn
179179+180180+ // @ts-expect-error include does not narrow the type unfortunately
181181+ parent.navigate(`${screen}Tab`, {screen, params})
182182+ return
183183+ } else {
184184+ // will probably fail, but let's try anyway
185185+ }
186186+ }
187187+ }
188188+158189 if (action === 'push') {
159159- navigation.dispatch(StackActions.push(...router.matchPath(href)))
190190+ navigation.dispatch(StackActions.push(screen, params))
160191 } else if (action === 'replace') {
161161- navigation.dispatch(
162162- StackActions.replace(...router.matchPath(href)),
163163- )
192192+ navigation.dispatch(StackActions.replace(screen, params))
164193 } else if (action === 'navigate') {
165165- // @ts-ignore
166166- navigation.navigate(...router.matchPath(href))
194194+ // @ts-expect-error not typed
195195+ navigation.navigate(screen, params)
167196 } else {
168197 throw Error('Unsupported navigator action.')
169198 }