nip5 handles
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import "./stream-page.css";
|
||||
import { parseNostrLink, TaggedRawEvent } from "@snort/system";
|
||||
import { unwrap } from "@snort/shared";
|
||||
import { NostrLink, NostrPrefix, TaggedRawEvent, tryParseNostrLink } from "@snort/system";
|
||||
import { fetchNip05Pubkey } from "@snort/shared";
|
||||
import { useLocation, useNavigate, useParams } from "react-router-dom";
|
||||
import { Helmet } from "react-helmet";
|
||||
|
||||
@ -10,6 +10,7 @@ import {
|
||||
findTag,
|
||||
getEventFromLocationState,
|
||||
getHost,
|
||||
hexToBech32,
|
||||
} from "utils";
|
||||
import { Profile, getName } from "element/profile";
|
||||
import { LiveChat } from "element/live-chat";
|
||||
@ -32,6 +33,7 @@ import {
|
||||
isContentWarningAccepted,
|
||||
} from "element/content-warning";
|
||||
import { useCurrentStreamFeed } from "hooks/current-stream-feed";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
function ProfileInfo({ ev, goal }: { ev?: NostrEvent; goal?: TaggedRawEvent }) {
|
||||
const login = useLogin();
|
||||
@ -111,14 +113,41 @@ function ProfileInfo({ ev, goal }: { ev?: NostrEvent; goal?: TaggedRawEvent }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function StreamPage() {
|
||||
export function StreamPageHandler() {
|
||||
const params = useParams();
|
||||
const location = useLocation();
|
||||
const evPreload = getEventFromLocationState(location.state);
|
||||
const link = parseNostrLink(unwrap(params.id));
|
||||
const [link, setLink] = useState<NostrLink>();
|
||||
|
||||
useEffect(() => {
|
||||
if (params.id) {
|
||||
const parsedLink = tryParseNostrLink(params.id);
|
||||
if (parsedLink) {
|
||||
setLink(parsedLink);
|
||||
} else {
|
||||
const [handle, domain] = (params.id.includes("@") ? params.id : `${params.id}@zap.stream`).split("@");
|
||||
fetchNip05Pubkey(handle, domain).then(d => {
|
||||
if (d) {
|
||||
setLink({
|
||||
id: d,
|
||||
type: NostrPrefix.PublicKey,
|
||||
encode: () => hexToBech32(NostrPrefix.PublicKey, d)
|
||||
} as NostrLink);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}, [params.id]);
|
||||
|
||||
if (link) {
|
||||
return <StreamPage link={link} evPreload={evPreload} />
|
||||
}
|
||||
}
|
||||
|
||||
export function StreamPage({ link, evPreload }: { evPreload?: NostrEvent, link: NostrLink }) {
|
||||
const ev = useCurrentStreamFeed(link, true, evPreload);
|
||||
const host = getHost(ev);
|
||||
const goal = useZapGoal(host, link, true);
|
||||
const goal = useZapGoal(host, createNostrLink(ev), true);
|
||||
|
||||
const title = findTag(ev, "title");
|
||||
const summary = findTag(ev, "summary");
|
||||
|
Reference in New Issue
Block a user