wait a sec before showing card (#3516)

zio/stable
Hailey 2024-04-12 16:51:07 -07:00 committed by GitHub
parent cefa0a55e8
commit 7d01ff90d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 9 deletions

View File

@ -62,8 +62,10 @@ export function ProfileHoverCardInner(props: ProfileHoverCardProps) {
const targetHovered = React.useRef(false)
const cardHovered = React.useRef(false)
const targetClicked = React.useRef(false)
const showTimeout = React.useRef<NodeJS.Timeout>()
const onPointerEnterTarget = React.useCallback(() => {
showTimeout.current = setTimeout(async () => {
targetHovered.current = true
if (prefetchedProfile.current) {
@ -71,13 +73,14 @@ export function ProfileHoverCardInner(props: ProfileHoverCardProps) {
if (targetClicked.current) return
setHovered(true)
} else {
prefetchProfileQuery(props.did).then(() => {
await prefetchProfileQuery(props.did)
if (targetHovered.current) {
setHovered(true)
}
prefetchedProfile.current = true
})
}
}, 350)
}, [props.did, prefetchProfileQuery])
const onPointerEnterCard = React.useCallback(() => {
cardHovered.current = true
@ -86,6 +89,7 @@ export function ProfileHoverCardInner(props: ProfileHoverCardProps) {
setHovered(true)
}, [])
const onPointerLeaveTarget = React.useCallback(() => {
clearTimeout(showTimeout.current)
targetHovered.current = false
setTimeout(() => {
if (cardHovered.current) return