Bluesky app fork with some witchin' additions 💫

[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.

authored by danabra.mov and committed by

GitHub ddf2a64a 3c30bb1d

+13 -4
+13 -4
src/view/com/util/Link.tsx
··· 18 18 useNavigationDeduped, 19 19 } from '#/lib/hooks/useNavigationDeduped' 20 20 import {useOpenLink} from '#/lib/hooks/useOpenLink' 21 + import {getTabState, TabState} from '#/lib/routes/helpers' 21 22 import { 22 23 convertBskyAppUrlIfNeeded, 23 24 isExternalUrl, ··· 25 26 } from '#/lib/strings/url-helpers' 26 27 import {TypographyVariant} from '#/lib/ThemeContext' 27 28 import {isAndroid, isWeb} from '#/platform/detection' 29 + import {emitSoftReset} from '#/state/events' 28 30 import {useModalControls} from '#/state/modals' 29 31 import {WebAuxClickWrapper} from '#/view/com/util/WebAuxClickWrapper' 30 32 import {useTheme} from '#/alf' ··· 400 402 } else { 401 403 closeModal() // close any active modals 402 404 405 + const [routeName, params] = router.matchPath(href) 403 406 if (navigationAction === 'push') { 404 407 // @ts-ignore we're not able to type check on this one -prf 405 - navigation.dispatch(StackActions.push(...router.matchPath(href))) 408 + navigation.dispatch(StackActions.push(routeName, params)) 406 409 } else if (navigationAction === 'replace') { 407 410 // @ts-ignore we're not able to type check on this one -prf 408 - navigation.dispatch(StackActions.replace(...router.matchPath(href))) 411 + navigation.dispatch(StackActions.replace(routeName, params)) 409 412 } else if (navigationAction === 'navigate') { 410 - // @ts-ignore we're not able to type check on this one -prf 411 - navigation.navigate(...router.matchPath(href)) 413 + const state = navigation.getState() 414 + const tabState = getTabState(state, routeName) 415 + if (tabState === TabState.InsideAtRoot) { 416 + emitSoftReset() 417 + } else { 418 + // @ts-ignore we're not able to type check on this one -prf 419 + navigation.navigate(routeName, params) 420 + } 412 421 } else { 413 422 throw Error('Unsupported navigator action.') 414 423 }