import "./stream-page.css"; import { NostrLink, TaggedNostrEvent } from "@snort/system"; import { useLocation, useNavigate } from "react-router-dom"; import { Helmet } from "react-helmet"; import { NostrEvent } from "@snort/system"; import { SnortContext, useUserProfile } from "@snort/system-react"; import { FormattedMessage } from "react-intl"; import { useContext } from "react"; import { LiveVideoPlayer } from "@/element/live-video-player"; import { findTag, getEventFromLocationState, getHost } from "@/utils"; import { Profile, getName } from "@/element/profile"; import { LiveChat } from "@/element/live-chat"; import AsyncButton from "@/element/async-button"; import { useLogin } from "@/hooks/login"; import { useZapGoal } from "@/hooks/goals"; import { StreamState } from "@/index"; import { SendZapsDialog } from "@/element/send-zap"; import { NewStreamDialog } from "@/element/new-stream"; import { Tags } from "@/element/tags"; import { StatePill } from "@/element/state-pill"; import { StreamCards } from "@/element/stream-cards"; import { formatSats } from "@/number"; import { StreamTimer } from "@/element/stream-time"; import { ShareMenu } from "@/element/share-menu"; import { ContentWarningOverlay, isContentWarningAccepted } from "@/element/content-warning"; import { useCurrentStreamFeed } from "@/hooks/current-stream-feed"; import { useStreamLink } from "@/hooks/stream-link"; import { FollowButton } from "@/element/follow-button"; function ProfileInfo({ ev, goal }: { ev?: NostrEvent; goal?: TaggedNostrEvent }) { const system = useContext(SnortContext); const login = useLogin(); const navigate = useNavigate(); const host = getHost(ev); const profile = useUserProfile(host); const zapTarget = profile?.lud16 ?? profile?.lud06; const status = findTag(ev, "status") ?? ""; const isMine = ev?.pubkey === login?.pubkey; async function deleteStream() { const pub = login?.publisher(); if (pub && ev) { const evDelete = await pub.delete(ev.id); console.debug(evDelete); await system.BroadcastEvent(evDelete); navigate("/"); } } const viewers = Number(findTag(ev, "current_participants") ?? "0"); return ( <>

{findTag(ev, "title")}

{findTag(ev, "summary")}

{viewers > 0 && ( )} {status === StreamState.Live && ( )} {ev && }
{isMine && (
{ev && }
)}
{ev && ( <> {zapTarget && ( )} )}
); } export function StreamPageHandler() { const location = useLocation(); const evPreload = getEventFromLocationState(location.state); const link = useStreamLink(); if (link) { return ; } } export function StreamPage({ link, evPreload }: { evPreload?: NostrEvent; link: NostrLink }) { const ev = useCurrentStreamFeed(link, true, evPreload); const host = getHost(ev); const evLink = ev ? NostrLink.fromEvent(ev) : undefined; const goal = useZapGoal(findTag(ev, "goal")); const title = findTag(ev, "title"); const summary = findTag(ev, "summary"); const image = findTag(ev, "image"); const status = findTag(ev, "status"); const stream = status === StreamState.Live ? findTag(ev, "streaming") : findTag(ev, "recording"); const contentWarning = findTag(ev, "content-warning"); const tags = ev?.tags.filter(a => a[0] === "t").map(a => a[1]) ?? []; if (contentWarning && !isContentWarningAccepted()) { return ; } const descriptionContent = [title, (summary?.length ?? 0) > 0 ? summary : "Nostr live streaming", ...tags].join(", "); return (
{`${title} - zap.stream`}
); }