Merge branch 'main' into profile

This commit is contained in:
Alejandro Gomez
2023-07-01 10:42:12 +02:00
24 changed files with 383 additions and 73 deletions

View File

@ -1,5 +1,4 @@
import "./stream-page.css";
import { useRef } from "react";
import { parseNostrLink, EventPublisher } from "@snort/system";
import { useNavigate, useParams } from "react-router-dom";
@ -10,20 +9,25 @@ import { Profile, getName } from "element/profile";
import { LiveChat } from "element/live-chat";
import AsyncButton from "element/async-button";
import { useLogin } from "hooks/login";
import { System } from "index";
import { StreamState, System } from "index";
import { SendZapsDialog } from "element/send-zap";
import type { NostrLink } from "@snort/system";
import { useUserProfile } from "@snort/system-react";
import { NewStreamDialog } from "element/new-stream";
import { Tags } from "element/tags";
import { StatePill } from "element/state-pill";
function ProfileInfo({ link }: { link: NostrLink }) {
const thisEvent = useEventFeed(link, true);
const login = useLogin();
const navigate = useNavigate();
const profile = useUserProfile(System, thisEvent.data?.pubkey);
const host =
thisEvent.data?.tags.find((a) => a[0] === "p" && a[3] === "host")?.[1] ??
thisEvent.data?.pubkey;
const profile = useUserProfile(System, host);
const zapTarget = profile?.lud16 ?? profile?.lud06;
const status = thisEvent?.data ? findTag(thisEvent.data, "status") : "";
const isMine = link.author === login?.pubkey;
async function deleteStream() {
@ -42,6 +46,7 @@ function ProfileInfo({ link }: { link: NostrLink }) {
<div className="f-grow stream-info">
<h1>{findTag(thisEvent.data, "title")}</h1>
<p>{findTag(thisEvent.data, "summary")}</p>
<StatePill state={status as StreamState} />
{thisEvent?.data && <Tags ev={thisEvent.data} />}
{isMine && (
<div className="actions">
@ -59,11 +64,15 @@ function ProfileInfo({ link }: { link: NostrLink }) {
)}
</div>
<div className="profile-info flex g24">
<Profile pubkey={thisEvent.data?.pubkey ?? ""} />
<Profile pubkey={host ?? ""} />
{zapTarget && thisEvent.data && (
<SendZapsDialog
lnurl={zapTarget}
ev={thisEvent.data}
pubkey={host}
aTag={`${thisEvent.data.kind}:${thisEvent.data.pubkey}:${findTag(
thisEvent.data,
"d"
)}`}
targetName={getName(thisEvent.data.pubkey, profile)}
/>
)}
@ -86,13 +95,11 @@ function VideoPlayer({ link }: { link: NostrLink }) {
}
export function StreamPage() {
const ref = useRef(null);
const params = useParams();
const link = parseNostrLink(params.id!);
return (
<>
<div ref={ref}></div>
<VideoPlayer link={link} />
<ProfileInfo link={link} />
<LiveChat link={link} />