diff options
author | Kuwa Lee <kuwalee1069@gmail.com> | 2024-06-16 20:04:56 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-16 20:04:56 +0800 |
commit | fa1dfe8b0a7c405d608eea72c20dfeef22d36715 (patch) | |
tree | 4bd21370fafe33e2ee093546a7377bfd71c82978 /src | |
parent | 01f505d09f35b642c5ea9206f10e1ff68f4eb0d5 (diff) | |
parent | 10c6035f310ba1a3a0420a4e013e2b2b30ddb374 (diff) | |
download | voidsky-fa1dfe8b0a7c405d608eea72c20dfeef22d36715.tar.zst |
Merge branch 'bluesky-social:main' into zh
Diffstat (limited to 'src')
-rw-r--r-- | src/components/ProfileHoverCard/index.web.tsx | 15 | ||||
-rw-r--r-- | src/view/com/util/PostMeta.tsx | 77 |
2 files changed, 45 insertions, 47 deletions
diff --git a/src/components/ProfileHoverCard/index.web.tsx b/src/components/ProfileHoverCard/index.web.tsx index e17977af4..4f110485e 100644 --- a/src/components/ProfileHoverCard/index.web.tsx +++ b/src/components/ProfileHoverCard/index.web.tsx @@ -51,10 +51,23 @@ const floatingMiddlewares = [ ] export function ProfileHoverCard(props: ProfileHoverCardProps) { + const prefetchProfileQuery = usePrefetchProfileQuery() + const prefetchedProfile = React.useRef(false) + const onPointerMove = () => { + if (!prefetchedProfile.current) { + prefetchedProfile.current = true + prefetchProfileQuery(props.did) + } + } + if (props.disable || isTouchDevice) { return props.children } else { - return <ProfileHoverCardInner {...props} /> + return ( + <View onPointerMove={onPointerMove}> + <ProfileHoverCardInner {...props} /> + </View> + ) } } diff --git a/src/view/com/util/PostMeta.tsx b/src/view/com/util/PostMeta.tsx index df45174b9..3f855c336 100644 --- a/src/view/com/util/PostMeta.tsx +++ b/src/view/com/util/PostMeta.tsx @@ -3,15 +3,14 @@ import {StyleProp, StyleSheet, TextStyle, View, ViewStyle} from 'react-native' import {AppBskyActorDefs, ModerationDecision, ModerationUI} from '@atproto/api' import {useQueryClient} from '@tanstack/react-query' -import {precacheProfile, usePrefetchProfileQuery} from '#/state/queries/profile' +import {precacheProfile} from '#/state/queries/profile' import {usePalette} from 'lib/hooks/usePalette' import {makeProfileLink} from 'lib/routes/links' import {sanitizeDisplayName} from 'lib/strings/display-names' 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 {isAndroid} from 'platform/detection' import {ProfileHoverCard} from '#/components/ProfileHoverCard' import {TextLinkOnWebOnly} from './Link' import {Text} from './text/Text' @@ -37,17 +36,7 @@ let PostMeta = (opts: PostMetaOpts): React.ReactNode => { const pal = usePalette('default') const displayName = opts.author.displayName || opts.author.handle const handle = opts.author.handle - const prefetchProfileQuery = usePrefetchProfileQuery() - const profileLink = makeProfileLink(opts.author) - 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 const onBeforePressAuthor = useCallback(() => { @@ -71,39 +60,35 @@ 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]}> - <TextLinkOnWebOnly - type={opts.displayNameType || 'lg-bold'} - style={[pal.text]} - lineHeight={1.2} - disableMismatchWarning - text={ - <> - {sanitizeDisplayName( - displayName, - opts.moderation?.ui('displayName'), - )} - </> - } - href={profileLink} - onBeforePress={onBeforePressAuthor} - /> - <TextLinkOnWebOnly - type="md" - disableMismatchWarning - style={[pal.textLight, {flexShrink: 4}]} - text={'\xa0' + sanitizeHandle(handle, '@')} - href={profileLink} - onBeforePress={onBeforePressAuthor} - anchorNoUnderline - /> - </Text> - </View> + <Text + numberOfLines={1} + style={[styles.maxWidth, pal.textLight, opts.displayNameStyle]}> + <TextLinkOnWebOnly + type={opts.displayNameType || 'lg-bold'} + style={[pal.text]} + lineHeight={1.2} + disableMismatchWarning + text={ + <> + {sanitizeDisplayName( + displayName, + opts.moderation?.ui('displayName'), + )} + </> + } + href={profileLink} + onBeforePress={onBeforePressAuthor} + /> + <TextLinkOnWebOnly + type="md" + disableMismatchWarning + style={[pal.textLight, {flexShrink: 4}]} + text={'\xa0' + sanitizeHandle(handle, '@')} + href={profileLink} + onBeforePress={onBeforePressAuthor} + anchorNoUnderline + /> + </Text> </ProfileHoverCard> {!isAndroid && ( <Text |