import "./ProfilePage.css"; import { useEffect, useMemo, useState } from "react"; import { useSelector } from "react-redux"; import { useNavigate, useParams } from "react-router-dom"; import Link from "Icons/Link"; import Zap from "Icons/Zap"; import Envelope from "Icons/Envelope"; import { useUserProfile } from "Feed/ProfileFeed"; import FollowButton from "Element/FollowButton"; import { extractLnAddress, parseId, hexToBech32 } from "Util"; import Avatar from "Element/Avatar"; import LogoutButton from "Element/LogoutButton"; import Timeline from "Element/Timeline"; import Text from 'Element/Text' import LNURLTip from "Element/LNURLTip"; import Nip05 from "Element/Nip05"; import Copy from "Element/Copy"; import ProfilePreview from "Element/ProfilePreview"; import FollowersList from "Element/FollowersList"; import BlockList from "Element/BlockList"; import MutedList from "Element/MutedList"; import FollowsList from "Element/FollowsList"; import { RootState } from "State/Store"; import { HexKey } from "Nostr"; import FollowsYou from "Element/FollowsYou" enum ProfileTab { Notes = "Notes", Reactions = "Reactions", Followers = "Followers", Follows = "Follows", Muted = "Muted", Blocked = "Blocked" }; export default function ProfilePage() { const params = useParams(); const navigate = useNavigate(); const id = useMemo(() => parseId(params.id!), [params]); const user = useUserProfile(id); const loggedOut = useSelector(s => s.login.loggedOut); const loginPubKey = useSelector(s => s.login.publicKey); const follows = useSelector(s => s.login.follows); const isMe = loginPubKey === id; const [showLnQr, setShowLnQr] = useState(false); const [tab, setTab] = useState(ProfileTab.Notes); const aboutText = user?.about || '' const about = Text({ content: user?.about || '', tags: [], users: new Map() }) const lnurl = extractLnAddress(user?.lud16 || user?.lud06 || ""); useEffect(() => { setTab(ProfileTab.Notes); }, [params]); function username() { return (

{user?.display_name || user?.name || 'Nostrich'}

{user?.nip05 && } {links()}
) } function links() { return (
{user?.website && ( )} setShowLnQr(false)} />
) } function bio() { return aboutText.length > 0 && ( <>

Bio

{about}
) } function tabContent() { switch (tab) { case ProfileTab.Notes: return ; case ProfileTab.Follows: { if (isMe) { return (

Following {follows.length}

{follows.map(a => )}
); } else { return ; } } case ProfileTab.Followers: { return } case ProfileTab.Muted: { return isMe ? : } case ProfileTab.Blocked: { return isMe ? : null } } } function avatar() { return (
) } function userDetails() { return (
{username()}
{isMe ? ( <> ) : ( <> {!loggedOut && ( <> )} )}
{bio()}
) } function renderTab(v: ProfileTab) { return
setTab(v)}>{v}
} return ( <>
{user?.banner && banner}
{avatar()} {userDetails()}
{[ProfileTab.Notes, ProfileTab.Followers, ProfileTab.Follows, ProfileTab.Muted].map(renderTab)} {isMe && renderTab(ProfileTab.Blocked)}
{tabContent()} ) }