Compare commits
2 Commits
21c6be9195
...
4e76aee818
Author | SHA1 | Date | |
---|---|---|---|
4e76aee818
|
|||
e400debde2
|
@ -65,15 +65,19 @@ export function StreamTile({
|
||||
const [videoLink, setVideoLink] = useState(`/${link.encode()}`)
|
||||
|
||||
useEffect(() => {
|
||||
fetchNostrAddresByPubkey(host, NIP5_DOMAIN).then((h) => {
|
||||
if (h) {
|
||||
const names = Object.entries(h.names);
|
||||
if (names.length > 0) {
|
||||
setVideoLink(`/${names[0][0]}`);
|
||||
if (status === StreamState.Live) {
|
||||
fetchNostrAddresByPubkey(host, NIP5_DOMAIN).then((h) => {
|
||||
if (h) {
|
||||
const names = Object.entries(h.names);
|
||||
if (names.length > 0) {
|
||||
setVideoLink(`/${names[0][0]}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}, [videoLink]);
|
||||
|
||||
});
|
||||
}
|
||||
}, [status, videoLink]);
|
||||
|
||||
const [hasImg, setHasImage] = useState((image?.length ?? 0) > 0 || (recording?.length ?? 0) > 0);
|
||||
return (
|
||||
<div
|
||||
|
@ -1,11 +1,12 @@
|
||||
import { NIP5_DOMAIN } from "@/const";
|
||||
import { fetchNip05Pubkey } from "@snort/shared";
|
||||
import { NostrLink, NostrPrefix, tryParseNostrLink } from "@snort/system";
|
||||
import { NostrEvent, NostrLink, NostrPrefix, tryParseNostrLink } from "@snort/system";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useParams } from "react-router-dom";
|
||||
|
||||
export function useStreamLink() {
|
||||
export function useStreamLink(evPreload?: NostrEvent) {
|
||||
const params = useParams();
|
||||
const [link, setLink] = useState<NostrLink>();
|
||||
const [link, setLink] = useState<NostrLink | undefined>(evPreload ? NostrLink.fromEvent(evPreload) : undefined);
|
||||
|
||||
useEffect(() => {
|
||||
if (params.id) {
|
||||
@ -13,7 +14,7 @@ export function useStreamLink() {
|
||||
if (parsedLink) {
|
||||
setLink(parsedLink);
|
||||
} else {
|
||||
const [handle, domain] = (params.id.includes("@") ? params.id : `${params.id}@zap.stream`).split("@");
|
||||
const [handle, domain] = (params.id.includes("@") ? params.id : `${params.id}@${NIP5_DOMAIN}`).split("@");
|
||||
fetchNip05Pubkey(handle, domain).then(d => {
|
||||
if (d) {
|
||||
setLink(new NostrLink(NostrPrefix.PublicKey, d));
|
||||
|
@ -14,7 +14,7 @@ import { ShortPage } from "./short";
|
||||
export function LinkHandler() {
|
||||
const location = useLocation();
|
||||
const evPreload = getEventFromLocationState(location.state);
|
||||
const link = useStreamLink();
|
||||
const link = useStreamLink(evPreload);
|
||||
const layoutContext = useLayout();
|
||||
|
||||
if (!link) return;
|
||||
|
Reference in New Issue
Block a user