import { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { UserStats } from '@app/users/components/stats'; import { useStorage } from '@libs/storage/provider'; import { EditProfileModal } from '@shared/editProfileModal'; import { Image } from '@shared/image'; import { useNostr } from '@utils/hooks/useNostr'; import { useProfile } from '@utils/hooks/useProfile'; import { shortenKey } from '@utils/shortenKey'; export function UserProfile({ pubkey }: { pubkey: string }) { const { db } = useStorage(); const { user } = useProfile(pubkey); const { addContact, removeContact } = useNostr(); const [followed, setFollowed] = useState(false); const followUser = (pubkey: string) => { try { addContact(pubkey); // update state setFollowed(true); } catch (error) { console.log(error); } }; const unfollowUser = (pubkey: string) => { try { removeContact(pubkey); // update state setFollowed(false); } catch (error) { console.log(error); } }; useEffect(() => { if (db.account.follows.includes(pubkey)) { setFollowed(true); } }, []); if (!user) return

Loading...

; return ( <>
{user.banner ? ( user banner ) : (
)}
{pubkey}
{user.display_name || user.displayName || user.name || 'No name'}
{user.nip05 || user.username || shortenKey(pubkey)}
{user.about || user.bio ? (

{user.about || user.bio}

) : ( <> )}
{followed ? ( ) : ( )} Message {db.account.pubkey === pubkey && ( <> )}
); }