diff options
author | dan <dan.abramov@gmail.com> | 2024-11-17 00:37:34 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-17 00:37:34 +0000 |
commit | ddf2a64a7287ee737099844b6885f9ceb8f65f75 (patch) | |
tree | 1b9df845100db82dd2302fff9f60f01344251099 /src/view/com/util/Link.tsx | |
parent | 3c30bb1d358c6544170b8d334c5ee0530020a566 (diff) | |
download | voidsky-ddf2a64a7287ee737099844b6885f9ceb8f65f75.tar.zst |
[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.
Diffstat (limited to 'src/view/com/util/Link.tsx')
-rw-r--r-- | src/view/com/util/Link.tsx | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/view/com/util/Link.tsx b/src/view/com/util/Link.tsx index 2cc3e30ca..489fbc59c 100644 --- a/src/view/com/util/Link.tsx +++ b/src/view/com/util/Link.tsx @@ -18,6 +18,7 @@ import { useNavigationDeduped, } from '#/lib/hooks/useNavigationDeduped' import {useOpenLink} from '#/lib/hooks/useOpenLink' +import {getTabState, TabState} from '#/lib/routes/helpers' import { convertBskyAppUrlIfNeeded, isExternalUrl, @@ -25,6 +26,7 @@ import { } from '#/lib/strings/url-helpers' import {TypographyVariant} from '#/lib/ThemeContext' import {isAndroid, isWeb} from '#/platform/detection' +import {emitSoftReset} from '#/state/events' import {useModalControls} from '#/state/modals' import {WebAuxClickWrapper} from '#/view/com/util/WebAuxClickWrapper' import {useTheme} from '#/alf' @@ -400,15 +402,22 @@ function onPressInner( } else { closeModal() // close any active modals + const [routeName, params] = router.matchPath(href) if (navigationAction === 'push') { // @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') { // @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') { - // @ts-ignore we're not able to type check on this one -prf - navigation.navigate(...router.matchPath(href)) + const state = navigation.getState() + 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 { throw Error('Unsupported navigator action.') } |