diff options
author | Samuel Newman <mozzius@protonmail.com> | 2025-07-15 07:48:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-15 07:48:24 +0300 |
commit | 4ccbae7c30307bd19a9bd4afa9f2039aed9da94c (patch) | |
tree | d6fd20b75c8d41a222b0f513bb5c9fee49f1d6ca /src/view/shell | |
parent | 1f82b1d5572c3944cf1f987e9090f8f626d67fcd (diff) | |
download | voidsky-4ccbae7c30307bd19a9bd4afa9f2039aed9da94c.tar.zst |
Fix perf issue on web - restore pop behaviour to tabs (#8620)
Diffstat (limited to 'src/view/shell')
-rw-r--r-- | src/view/shell/desktop/LeftNav.tsx | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/view/shell/desktop/LeftNav.tsx b/src/view/shell/desktop/LeftNav.tsx index 52df66d70..ee2b1778b 100644 --- a/src/view/shell/desktop/LeftNav.tsx +++ b/src/view/shell/desktop/LeftNav.tsx @@ -3,11 +3,7 @@ import {StyleSheet, View} from 'react-native' import {type AppBskyActorDefs} from '@atproto/api' import {msg, plural, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' -import { - useLinkTo, - useNavigation, - useNavigationState, -} from '@react-navigation/native' +import {useNavigation, useNavigationState} from '@react-navigation/native' import {useActorStatus} from '#/lib/actor-status' import {useAccountSwitcher} from '#/lib/hooks/useAccountSwitcher' @@ -16,7 +12,10 @@ import {usePalette} from '#/lib/hooks/usePalette' import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' import {getCurrentRoute, isTab} from '#/lib/routes/helpers' import {makeProfileLink} from '#/lib/routes/links' -import {type CommonNavigatorParams} from '#/lib/routes/types' +import { + type CommonNavigatorParams, + type NavigationProp, +} from '#/lib/routes/types' import {useGate} from '#/lib/statsig/statsig' import {sanitizeDisplayName} from '#/lib/strings/display-names' import {isInvalidHandle, sanitizeHandle} from '#/lib/strings/handles' @@ -339,7 +338,7 @@ function NavItem({count, hasNew, href, icon, iconFilled, label}: NavItemProps) { (currentRouteInfo.params as CommonNavigatorParams['Profile']).name === currentAccount?.handle : isTab(currentRouteInfo.name, pathName) - const linkTo = useLinkTo() + const navigation = useNavigation<NavigationProp>() const onPressWrapped = useCallback( (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => { if (e.ctrlKey || e.metaKey || e.altKey) { @@ -349,10 +348,12 @@ function NavItem({count, hasNew, href, icon, iconFilled, label}: NavItemProps) { if (isCurrent) { emitSoftReset() } else { - linkTo(href) + const [screen, params] = router.matchPath(href) + // @ts-expect-error TODO: type matchPath well enough that it can be plugged into navigation.navigate directly + navigation.popTo(screen, params) } }, - [linkTo, href, isCurrent], + [navigation, href, isCurrent], ) return ( |