Setup lang
This commit is contained in:
@ -1,22 +1,11 @@
|
||||
import "./stream-page.css";
|
||||
import {
|
||||
NostrLink,
|
||||
NostrPrefix,
|
||||
TaggedNostrEvent,
|
||||
tryParseNostrLink,
|
||||
} from "@snort/system";
|
||||
import { NostrLink, NostrPrefix, TaggedNostrEvent, tryParseNostrLink } from "@snort/system";
|
||||
import { fetchNip05Pubkey } from "@snort/shared";
|
||||
import { useLocation, useNavigate, useParams } from "react-router-dom";
|
||||
import { Helmet } from "react-helmet";
|
||||
|
||||
import { LiveVideoPlayer } from "element/live-video-player";
|
||||
import {
|
||||
createNostrLink,
|
||||
findTag,
|
||||
getEventFromLocationState,
|
||||
getHost,
|
||||
hexToBech32,
|
||||
} from "utils";
|
||||
import { createNostrLink, findTag, getEventFromLocationState, getHost, hexToBech32 } from "utils";
|
||||
import { Profile, getName } from "element/profile";
|
||||
import { LiveChat } from "element/live-chat";
|
||||
import AsyncButton from "element/async-button";
|
||||
@ -33,20 +22,11 @@ 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 { ContentWarningOverlay, isContentWarningAccepted } from "element/content-warning";
|
||||
import { useCurrentStreamFeed } from "hooks/current-stream-feed";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
function ProfileInfo({
|
||||
ev,
|
||||
goal,
|
||||
}: {
|
||||
ev?: NostrEvent;
|
||||
goal?: TaggedNostrEvent;
|
||||
}) {
|
||||
function ProfileInfo({ ev, goal }: { ev?: NostrEvent; goal?: TaggedNostrEvent }) {
|
||||
const login = useLogin();
|
||||
const navigate = useNavigate();
|
||||
const host = getHost(ev);
|
||||
@ -75,11 +55,7 @@ function ProfileInfo({
|
||||
<p>{findTag(ev, "summary")}</p>
|
||||
<div className="tags">
|
||||
<StatePill state={status as StreamState} />
|
||||
{viewers > 0 && (
|
||||
<span className="pill viewers">
|
||||
{formatSats(viewers)} viewers
|
||||
</span>
|
||||
)}
|
||||
{viewers > 0 && <span className="pill viewers">{formatSats(viewers)} viewers</span>}
|
||||
{status === StreamState.Live && (
|
||||
<span className="pill">
|
||||
<StreamTimer ev={ev} />
|
||||
@ -90,11 +66,7 @@ function ProfileInfo({
|
||||
{isMine && (
|
||||
<div className="actions">
|
||||
{ev && <NewStreamDialog text="Edit" ev={ev} btnClassName="btn" />}
|
||||
<AsyncButton
|
||||
type="button"
|
||||
className="btn btn-warning"
|
||||
onClick={deleteStream}
|
||||
>
|
||||
<AsyncButton type="button" className="btn btn-warning" onClick={deleteStream}>
|
||||
Delete
|
||||
</AsyncButton>
|
||||
</div>
|
||||
@ -136,10 +108,8 @@ export function StreamPageHandler() {
|
||||
if (parsedLink) {
|
||||
setLink(parsedLink);
|
||||
} else {
|
||||
const [handle, domain] = (
|
||||
params.id.includes("@") ? params.id : `${params.id}@zap.stream`
|
||||
).split("@");
|
||||
fetchNip05Pubkey(handle, domain).then((d) => {
|
||||
const [handle, domain] = (params.id.includes("@") ? params.id : `${params.id}@zap.stream`).split("@");
|
||||
fetchNip05Pubkey(handle, domain).then(d => {
|
||||
if (d) {
|
||||
setLink({
|
||||
id: d,
|
||||
@ -157,13 +127,7 @@ export function StreamPageHandler() {
|
||||
}
|
||||
}
|
||||
|
||||
export function StreamPage({
|
||||
link,
|
||||
evPreload,
|
||||
}: {
|
||||
evPreload?: NostrEvent;
|
||||
link: NostrLink;
|
||||
}) {
|
||||
export function StreamPage({ link, evPreload }: { evPreload?: NostrEvent; link: NostrLink }) {
|
||||
const ev = useCurrentStreamFeed(link, true, evPreload);
|
||||
const host = getHost(ev);
|
||||
const goal = useZapGoal(host, createNostrLink(ev), true);
|
||||
@ -172,31 +136,21 @@ export function StreamPage({
|
||||
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 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]) ?? [];
|
||||
const tags = ev?.tags.filter(a => a[0] === "t").map(a => a[1]) ?? [];
|
||||
|
||||
if (contentWarning && !isContentWarningAccepted()) {
|
||||
return <ContentWarningOverlay />;
|
||||
}
|
||||
|
||||
const descriptionContent = [
|
||||
title,
|
||||
(summary?.length ?? 0) > 0 ? summary : "Nostr live streaming",
|
||||
...tags,
|
||||
].join(", ");
|
||||
const descriptionContent = [title, (summary?.length ?? 0) > 0 ? summary : "Nostr live streaming", ...tags].join(", ");
|
||||
return (
|
||||
<div className="stream-page">
|
||||
<Helmet>
|
||||
<title>{`${title} - zap.stream`}</title>
|
||||
<meta name="description" content={descriptionContent} />
|
||||
<meta
|
||||
property="og:url"
|
||||
content={`https://${window.location.host}/${link.encode()}`}
|
||||
/>
|
||||
<meta property="og:url" content={`https://${window.location.host}/${link.encode()}`} />
|
||||
<meta property="og:type" content="video" />
|
||||
<meta property="og:title" content={title} />
|
||||
<meta property="og:description" content={descriptionContent} />
|
||||
|
Reference in New Issue
Block a user