[Web] Clicking root link twice refreshes the screen (#6434)

* [Web] Clicking root link twice refreshes the screen

* Scope it to navigation action

In practice this means -- just for the bottom mobile web tab bar.
This commit is contained in:
dan
2024-11-17 00:37:34 +00:00
committed by GitHub
parent 3c30bb1d35
commit ddf2a64a72
+13 -4
View File
@@ -18,6 +18,7 @@ import {
useNavigationDeduped, useNavigationDeduped,
} from '#/lib/hooks/useNavigationDeduped' } from '#/lib/hooks/useNavigationDeduped'
import {useOpenLink} from '#/lib/hooks/useOpenLink' import {useOpenLink} from '#/lib/hooks/useOpenLink'
import {getTabState, TabState} from '#/lib/routes/helpers'
import { import {
convertBskyAppUrlIfNeeded, convertBskyAppUrlIfNeeded,
isExternalUrl, isExternalUrl,
@@ -25,6 +26,7 @@ import {
} from '#/lib/strings/url-helpers' } from '#/lib/strings/url-helpers'
import {TypographyVariant} from '#/lib/ThemeContext' import {TypographyVariant} from '#/lib/ThemeContext'
import {isAndroid, isWeb} from '#/platform/detection' import {isAndroid, isWeb} from '#/platform/detection'
import {emitSoftReset} from '#/state/events'
import {useModalControls} from '#/state/modals' import {useModalControls} from '#/state/modals'
import {WebAuxClickWrapper} from '#/view/com/util/WebAuxClickWrapper' import {WebAuxClickWrapper} from '#/view/com/util/WebAuxClickWrapper'
import {useTheme} from '#/alf' import {useTheme} from '#/alf'
@@ -400,15 +402,22 @@ function onPressInner(
} else { } else {
closeModal() // close any active modals closeModal() // close any active modals
const [routeName, params] = router.matchPath(href)
if (navigationAction === 'push') { if (navigationAction === 'push') {
// @ts-ignore we're not able to type check on this one -prf // @ts-ignore we're not able to type check on this one -prf
navigation.dispatch(StackActions.push(...router.matchPath(href))) navigation.dispatch(StackActions.push(routeName, params))
} else if (navigationAction === 'replace') { } else if (navigationAction === 'replace') {
// @ts-ignore we're not able to type check on this one -prf // @ts-ignore we're not able to type check on this one -prf
navigation.dispatch(StackActions.replace(...router.matchPath(href))) navigation.dispatch(StackActions.replace(routeName, params))
} else if (navigationAction === 'navigate') { } else if (navigationAction === 'navigate') {
// @ts-ignore we're not able to type check on this one -prf const state = navigation.getState()
navigation.navigate(...router.matchPath(href)) const tabState = getTabState(state, routeName)
if (tabState === TabState.InsideAtRoot) {
emitSoftReset()
} else {
// @ts-ignore we're not able to type check on this one -prf
navigation.navigate(routeName, params)
}
} else { } else {
throw Error('Unsupported navigator action.') throw Error('Unsupported navigator action.')
} }