Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Prefetch profile links on web (#2634)

authored by

dan and committed by
GitHub
23a4bbf6 15740413

+34 -1
+17
src/state/queries/profile.ts
··· 57 57 }) 58 58 } 59 59 60 + export function usePrefetchProfileQuery() { 61 + const queryClient = useQueryClient() 62 + const prefetchProfileQuery = useCallback( 63 + (did: string) => { 64 + queryClient.prefetchQuery({ 65 + queryKey: RQKEY(did), 66 + queryFn: async () => { 67 + const res = await getAgent().getProfile({actor: did || ''}) 68 + return res.data 69 + }, 70 + }) 71 + }, 72 + [queryClient], 73 + ) 74 + return prefetchProfileQuery 75 + } 76 + 60 77 interface ProfileUpdateParams { 61 78 profile: AppBskyActorDefs.ProfileView 62 79 updates:
+2
src/view/com/util/Link.tsx
··· 47 47 asAnchor?: boolean 48 48 anchorNoUnderline?: boolean 49 49 navigationAction?: 'push' | 'replace' | 'navigate' 50 + onPointerEnter?: () => void 50 51 } 51 52 52 53 export const Link = memo(function Link({ ··· 264 265 accessibilityHint?: string 265 266 title?: string 266 267 navigationAction?: 'push' | 'replace' | 'navigate' 268 + onPointerEnter?: () => void 267 269 } 268 270 export const TextLinkOnWebOnly = memo(function DesktopWebTextLink({ 269 271 testID,
+8 -1
src/view/com/util/PostMeta.tsx
··· 8 8 import {UserAvatar} from './UserAvatar' 9 9 import {sanitizeDisplayName} from 'lib/strings/display-names' 10 10 import {sanitizeHandle} from 'lib/strings/handles' 11 - import {isAndroid} from 'platform/detection' 11 + import {isAndroid, isWeb} from 'platform/detection' 12 12 import {TimeElapsed} from './TimeElapsed' 13 13 import {makeProfileLink} from 'lib/routes/links' 14 14 import {ModerationUI} from '@atproto/api' 15 + import {usePrefetchProfileQuery} from '#/state/queries/profile' 15 16 16 17 interface PostMetaOpts { 17 18 author: { ··· 35 36 const pal = usePalette('default') 36 37 const displayName = opts.author.displayName || opts.author.handle 37 38 const handle = opts.author.handle 39 + const prefetchProfileQuery = usePrefetchProfileQuery() 38 40 39 41 return ( 40 42 <View style={[styles.container, opts.style]}> ··· 66 68 </> 67 69 } 68 70 href={makeProfileLink(opts.author)} 71 + onPointerEnter={() => { 72 + if (isWeb) { 73 + prefetchProfileQuery(opts.author.did) 74 + } 75 + }} 69 76 /> 70 77 </View> 71 78 {!isAndroid && (
+7
src/view/com/util/UserPreviewLink.tsx
··· 4 4 import {isAndroid, isWeb} from 'platform/detection' 5 5 import {makeProfileLink} from 'lib/routes/links' 6 6 import {useModalControls} from '#/state/modals' 7 + import {usePrefetchProfileQuery} from '#/state/queries/profile' 7 8 8 9 interface UserPreviewLinkProps { 9 10 did: string ··· 14 15 props: React.PropsWithChildren<UserPreviewLinkProps>, 15 16 ) { 16 17 const {openModal} = useModalControls() 18 + const prefetchProfileQuery = usePrefetchProfileQuery() 17 19 18 20 if (isWeb || isAndroid) { 19 21 return ( 20 22 <Link 23 + onPointerEnter={() => { 24 + if (isWeb) { 25 + prefetchProfileQuery(props.did) 26 + } 27 + }} 21 28 href={makeProfileLink(props)} 22 29 title={props.handle} 23 30 asAnchor