import { useArk, useProfile } from "@lume/ark"; import { useStorage } from "@lume/storage"; import { NIP05 } from "@lume/ui"; import { displayNpub } from "@lume/utils"; import * as Avatar from "@radix-ui/react-avatar"; import { minidenticon } from "minidenticons"; import { useEffect, useState } from "react"; import { Link, useNavigate } from "react-router-dom"; import { toast } from "sonner"; import { UserStats } from "./stats"; export function UserProfile({ pubkey }: { pubkey: string }) { const ark = useArk(); const storage = useStorage(); const { user } = useProfile(pubkey); const [followed, setFollowed] = useState(false); const navigate = useNavigate(); const svgURI = `data:image/svg+xml;utf8,${encodeURIComponent( minidenticon(pubkey, 90, 50), )}`; const follow = async () => { try { if (!ark.ndk.signer) return navigate("/new/privkey"); setFollowed(true); const add = await ark.createContact({ pubkey }); if (!add) { toast.success("You already follow this user"); setFollowed(false); } } catch (e) { toast.error(e); setFollowed(false); } }; const unfollow = async () => { try { if (!ark.ndk.signer) return navigate("/new/privkey"); setFollowed(false); await ark.deleteContact({ pubkey }); } catch (e) { toast.error(e); } }; useEffect(() => { if (ark.account.contacts.includes(pubkey)) { setFollowed(true); } }, []); if (!user) return
Loading...
; return ( <>{user.about || user.bio}
) : ( )}