import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/components/ui/hover-card' import { Skeleton } from '@/components/ui/skeleton' import { useFetchProfile } from '@/hooks' import { toProfile } from '@/lib/link' import { cn, isTouchDevice } from '@/lib/utils' import { SecondaryPageLink } from '@/PageManager' import { useMemo } from 'react' import NpubQrCode from '../NpubQrCode' import ProfileCard from '../ProfileCard' import TextWithEmojis from '../TextWithEmojis' export default function Username({ userId, showAt = false, className, skeletonClassName, withoutSkeleton = false, showQrCode = true }: { userId: string showAt?: boolean className?: string skeletonClassName?: string withoutSkeleton?: boolean showQrCode?: boolean }) { const { profile, isFetching } = useFetchProfile(userId) const supportTouch = useMemo(() => isTouchDevice(), []) if (!profile && isFetching && !withoutSkeleton) { return (
) } if (!profile) return null const usernameLink = ( e.stopPropagation()} > {showAt && '@'} ) const trigger = (
{usernameLink} {showQrCode && }
) if (supportTouch) { return trigger } return ( {trigger} ) } export function SimpleUsername({ userId, showAt = false, className, skeletonClassName, withoutSkeleton = false, showQrCode = true }: { userId: string showAt?: boolean className?: string skeletonClassName?: string withoutSkeleton?: boolean showQrCode?: boolean }) { const { profile, isFetching } = useFetchProfile(userId) if (!profile && isFetching && !withoutSkeleton) { return (
) } if (!profile) return null const { username, emojis } = profile return (
{showAt && '@'} {showQrCode && }
) }