feat: embed player

This commit is contained in:
2024-01-15 12:47:32 +00:00
parent 5c1a143a7d
commit 88e2250c33
5 changed files with 53 additions and 14 deletions

View File

@ -1,6 +1,6 @@
import { unwrap } from "@snort/shared";
import { NostrEvent, NostrLink, NostrPrefix, RequestBuilder, TaggedNostrEvent } from "@snort/system";
import { useRequestBuilderAdvanced } from "@snort/system-react";
import { NostrEvent, NostrLink, NostrPrefix, RequestBuilder } from "@snort/system";
import { useRequestBuilder } from "@snort/system-react";
import { useMemo } from "react";
import { LIVE_STREAM } from "@/const";
@ -27,14 +27,10 @@ export function useCurrentStreamFeed(link: NostrLink, leaveOpen = false, evPrelo
return b;
}, [link.id, leaveOpen]);
const q = useRequestBuilderAdvanced(sub);
if (evPreload) {
q?.feed.add([evPreload as TaggedNostrEvent]);
}
const q = useRequestBuilder(sub);
return useMemo(() => {
const hosting = q?.snapshot?.filter(
const hosting = [...q, ...(evPreload ? [evPreload] : [])].filter(
a => a.pubkey === author || a.tags.some(b => b[0] === "p" && b[1] === author && b[3] === "host")
);
return [...(hosting ?? [])].sort((a, b) => (b.created_at > a.created_at ? 1 : -1)).at(0);