Bluesky app fork with some witchin' additions 💫

Fix perf issue on web - restore pop behaviour to tabs (#8620)

authored by samuel.fm and committed by

GitHub 4ccbae7c 1f82b1d5

+22 -13
+1 -1
src/components/Link.tsx
··· 192 192 navigation.dispatch(StackActions.replace(screen, params)) 193 193 } else if (action === 'navigate') { 194 194 // @ts-expect-error not typed 195 - navigation.navigate(screen, params) 195 + navigation.navigate(screen, params, {pop: true}) 196 196 } else { 197 197 throw Error('Unsupported navigator action.') 198 198 }
-1
src/components/StarterPack/StarterPackCard.tsx
··· 156 156 157 157 return ( 158 158 <BaseLink 159 - action="push" 160 159 to={`/starter-pack/${handleOrDid}/${rkey}`} 161 160 label={_(msg`Navigate to ${record.name}`)} 162 161 onPress={() => {
+8
src/lib/hooks/useNavigationDeduped.ts
··· 7 7 export type DebouncedNavigationProp = Pick< 8 8 NavigationProp, 9 9 | 'popToTop' 10 + | 'popTo' 11 + | 'pop' 10 12 | 'push' 11 13 | 'navigate' 12 14 | 'canGoBack' ··· 37 39 }, 38 40 popToTop: () => { 39 41 dedupe(() => navigation.popToTop()) 42 + }, 43 + popTo: (...args: Parameters<typeof navigation.popTo>) => { 44 + dedupe(() => navigation.popTo(...args)) 45 + }, 46 + pop: (...args: Parameters<typeof navigation.pop>) => { 47 + dedupe(() => navigation.pop(...args)) 40 48 }, 41 49 goBack: () => { 42 50 dedupe(() => navigation.goBack())
+3 -2
src/view/com/util/Link.tsx
··· 11 11 type ViewStyle, 12 12 } from 'react-native' 13 13 import {sanitizeUrl} from '@braintree/sanitize-url' 14 - import {StackActions} from '@react-navigation/native' 15 14 16 15 import { 17 16 type DebouncedNavigationProp, ··· 421 420 if (tabState === TabState.InsideAtRoot) { 422 421 emitSoftReset() 423 422 } else { 423 + // note: 'navigate' actually acts the same as 'push' nowadays 424 + // therefore we need to add 'pop' -sfn 424 425 // @ts-ignore we're not able to type check on this one -prf 425 - navigation.navigate(routeName, params) 426 + navigation.navigate(routeName, params, {pop: true}) 426 427 } 427 428 } else { 428 429 throw Error('Unsupported navigator action.')
+10 -9
src/view/shell/desktop/LeftNav.tsx
··· 3 3 import {type AppBskyActorDefs} from '@atproto/api' 4 4 import {msg, plural, Trans} from '@lingui/macro' 5 5 import {useLingui} from '@lingui/react' 6 - import { 7 - useLinkTo, 8 - useNavigation, 9 - useNavigationState, 10 - } from '@react-navigation/native' 6 + import {useNavigation, useNavigationState} from '@react-navigation/native' 11 7 12 8 import {useActorStatus} from '#/lib/actor-status' 13 9 import {useAccountSwitcher} from '#/lib/hooks/useAccountSwitcher' ··· 16 12 import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' 17 13 import {getCurrentRoute, isTab} from '#/lib/routes/helpers' 18 14 import {makeProfileLink} from '#/lib/routes/links' 19 - import {type CommonNavigatorParams} from '#/lib/routes/types' 15 + import { 16 + type CommonNavigatorParams, 17 + type NavigationProp, 18 + } from '#/lib/routes/types' 20 19 import {useGate} from '#/lib/statsig/statsig' 21 20 import {sanitizeDisplayName} from '#/lib/strings/display-names' 22 21 import {isInvalidHandle, sanitizeHandle} from '#/lib/strings/handles' ··· 339 338 (currentRouteInfo.params as CommonNavigatorParams['Profile']).name === 340 339 currentAccount?.handle 341 340 : isTab(currentRouteInfo.name, pathName) 342 - const linkTo = useLinkTo() 341 + const navigation = useNavigation<NavigationProp>() 343 342 const onPressWrapped = useCallback( 344 343 (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => { 345 344 if (e.ctrlKey || e.metaKey || e.altKey) { ··· 349 348 if (isCurrent) { 350 349 emitSoftReset() 351 350 } else { 352 - linkTo(href) 351 + const [screen, params] = router.matchPath(href) 352 + // @ts-expect-error TODO: type matchPath well enough that it can be plugged into navigation.navigate directly 353 + navigation.popTo(screen, params) 353 354 } 354 355 }, 355 - [linkTo, href, isCurrent], 356 + [navigation, href, isCurrent], 356 357 ) 357 358 358 359 return (