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