Set profile hover prefetch stale time to 30s (#4417)
* Set prefetch stale time to 30s * Run prefetch on mouseOver * Only prefetch once on mousemovezio/stable
parent
247af5aee9
commit
d989128e5b
|
@ -94,6 +94,7 @@ export function usePrefetchProfileQuery() {
|
|||
const prefetchProfileQuery = useCallback(
|
||||
async (did: string) => {
|
||||
await queryClient.prefetchQuery({
|
||||
staleTime: STALE.SECONDS.THIRTY,
|
||||
queryKey: RQKEY(did),
|
||||
queryFn: async () => {
|
||||
const res = await agent.getProfile({actor: did || ''})
|
||||
|
|
|
@ -11,6 +11,7 @@ import {sanitizeHandle} from 'lib/strings/handles'
|
|||
import {niceDate} from 'lib/strings/time'
|
||||
import {TypographyVariant} from 'lib/ThemeContext'
|
||||
import {isAndroid, isWeb} from 'platform/detection'
|
||||
import {atoms as a} from '#/alf'
|
||||
import {ProfileHoverCard} from '#/components/ProfileHoverCard'
|
||||
import {TextLinkOnWebOnly} from './Link'
|
||||
import {Text} from './text/Text'
|
||||
|
@ -39,9 +40,13 @@ let PostMeta = (opts: PostMetaOpts): React.ReactNode => {
|
|||
const prefetchProfileQuery = usePrefetchProfileQuery()
|
||||
|
||||
const profileLink = makeProfileLink(opts.author)
|
||||
const onPointerEnter = isWeb
|
||||
? () => prefetchProfileQuery(opts.author.did)
|
||||
: undefined
|
||||
const prefetchedProfile = React.useRef(false)
|
||||
const onPointerMove = React.useCallback(() => {
|
||||
if (!prefetchedProfile.current) {
|
||||
prefetchedProfile.current = true
|
||||
prefetchProfileQuery(opts.author.did)
|
||||
}
|
||||
}, [opts.author.did, prefetchProfileQuery])
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const onOpenAuthor = opts.onOpenAuthor
|
||||
|
@ -66,6 +71,9 @@ let PostMeta = (opts: PostMetaOpts): React.ReactNode => {
|
|||
</View>
|
||||
)}
|
||||
<ProfileHoverCard inline did={opts.author.did}>
|
||||
<View
|
||||
onPointerMove={isWeb ? onPointerMove : undefined}
|
||||
style={[a.flex_1]}>
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
style={[styles.maxWidth, pal.textLight, opts.displayNameStyle]}>
|
||||
|
@ -84,7 +92,6 @@ let PostMeta = (opts: PostMetaOpts): React.ReactNode => {
|
|||
}
|
||||
href={profileLink}
|
||||
onBeforePress={onBeforePressAuthor}
|
||||
onPointerEnter={onPointerEnter}
|
||||
/>
|
||||
<TextLinkOnWebOnly
|
||||
type="md"
|
||||
|
@ -93,10 +100,10 @@ let PostMeta = (opts: PostMetaOpts): React.ReactNode => {
|
|||
text={'\xa0' + sanitizeHandle(handle, '@')}
|
||||
href={profileLink}
|
||||
onBeforePress={onBeforePressAuthor}
|
||||
onPointerEnter={onPointerEnter}
|
||||
anchorNoUnderline
|
||||
/>
|
||||
</Text>
|
||||
</View>
|
||||
</ProfileHoverCard>
|
||||
{!isAndroid && (
|
||||
<Text
|
||||
|
|
Loading…
Reference in New Issue