Prefetch profile links on web (#2634)

This commit is contained in:
dan 2024-01-26 05:23:56 +00:00 committed by GitHub
parent 157404132f
commit 23a4bbf608
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 34 additions and 1 deletions

View file

@ -4,6 +4,7 @@ import {Link} from './Link'
import {isAndroid, isWeb} from 'platform/detection'
import {makeProfileLink} from 'lib/routes/links'
import {useModalControls} from '#/state/modals'
import {usePrefetchProfileQuery} from '#/state/queries/profile'
interface UserPreviewLinkProps {
did: string
@ -14,10 +15,16 @@ export function UserPreviewLink(
props: React.PropsWithChildren<UserPreviewLinkProps>,
) {
const {openModal} = useModalControls()
const prefetchProfileQuery = usePrefetchProfileQuery()
if (isWeb || isAndroid) {
return (
<Link
onPointerEnter={() => {
if (isWeb) {
prefetchProfileQuery(props.did)
}
}}
href={makeProfileLink(props)}
title={props.handle}
asAnchor