import "./profile-page.css"; import { useMemo } from "react"; import { useNavigate, useParams } from "react-router-dom"; import { CachedMetadata, NostrEvent, NostrLink, TaggedNostrEvent, parseNostrLink } from "@snort/system"; import { useUserProfile } from "@snort/system-react"; import { unwrap } from "@snort/shared"; import { FormattedMessage } from "react-intl"; import { Icon } from "@/element/icon"; import { SendZapsDialog } from "@/element/send-zap"; import { VideoTile } from "@/element/video-tile"; import { FollowButton } from "@/element/follow-button"; import { MuteButton } from "@/element/mute-button"; import { useProfile } from "@/hooks/profile"; import { Text } from "@/element/text"; import { findTag } from "@/utils"; import { StatePill } from "@/element/state-pill"; import { Avatar } from "@/element/avatar"; import { StreamState } from "@/const"; import { DefaultButton } from "@/element/buttons"; import { useGoals } from "@/hooks/goals"; import { Goal } from "@/element/goal"; import { TopZappers } from "@/element/top-zappers"; import { useProfileClips } from "@/hooks/clips"; import VideoGrid from "@/element/video-grid"; import { ClipTile } from "@/element/stream/clip-tile"; const defaultBanner = "https://void.cat/d/Hn1AdN5UKmceuDkgDW847q.webp"; export function ProfilePage() { const params = useParams(); const link = parseNostrLink(unwrap(params.npub)); const { streams, zaps } = useProfile(link, true); const profile = useUserProfile(link.id); const pastStreams = useMemo(() => { return streams.filter(ev => findTag(ev, "status") === StreamState.Ended); }, [streams]); return (
{profile?.name

); } function ProfileHeader({ profile, link, streams, }: { profile?: CachedMetadata; link: NostrLink; streams: Array; }) { const navigate = useNavigate(); const liveEvent = useMemo(() => { return streams.find(ev => findTag(ev, "status") === StreamState.Live); }, [streams]); const zapTarget = profile?.lud16 ?? profile?.lud06; const isLive = Boolean(liveEvent); function goToLive() { if (liveEvent) { const evLink = NostrLink.fromEvent(liveEvent); navigate(`/${evLink.encode()}`); } } return (
{isLive && }
{profile?.name &&

{profile.name}

} {profile?.about && (

)}
{zapTarget && ( } targetName={profile?.name || link.id} /> )}
); } function ProfileStreamList({ streams }: { streams: Array }) { if (streams.length === 0) { return ; } return ( {streams.map(ev => (
))}
); } function ProfileZapGoals({ link }: { link: NostrLink }) { const limit = 5; const goals = useGoals(link.id, false, limit); if (goals.length === 0) { return ; } return goals .sort((a, b) => (a.created_at > b.created_at ? -1 : 1)) .slice(0, limit) .map(a => (
)); } function ProfileClips({ link }: { link: NostrLink }) { const clips = useProfileClips(link, 10); if (clips.length === 0) { return ; } return clips.map(a => ); }