import { commands } from "@/commands.gen"; import { displayLongHandle, displayNpub } from "@/commons"; import { SealCheck } from "@phosphor-icons/react"; import * as Tooltip from "@radix-ui/react-tooltip"; import { useQuery } from "@tanstack/react-query"; import { useUserContext } from "./provider"; export function UserNip05() { const user = useUserContext(); const { isLoading, data: verified } = useQuery({ queryKey: ["nip05", user?.pubkey], queryFn: async () => { const res = await commands.verifyNip05(user.pubkey, user.profile?.nip05); if (res.status === "ok") { return res.data; } else { throw new Error(res.error); } }, enabled: !!user.profile?.nip05?.length, refetchOnMount: false, refetchOnWindowFocus: false, refetchOnReconnect: false, staleTime: Number.POSITIVE_INFINITY, retry: false, }); if (!user.profile?.nip05?.length) return; return ( {!isLoading && verified ? ( ) : null} {!user.profile?.nip05 ? displayNpub(user.pubkey, 16) : user.profile?.nip05.length > 50 ? displayLongHandle(user.profile?.nip05) : user.profile.nip05?.replace("_@", "")} ); }