From ba62f0ef746057717b616187fa2b0572e8b6761c Mon Sep 17 00:00:00 2001 From: Kieran Date: Wed, 7 May 2025 14:15:07 +0100 Subject: [PATCH] feat: link to nests from live streams header --- .../src/Components/LiveStream/LiveStreams.tsx | 50 +++++++++++++++++-- .../app/src/Components/LiveStream/livekit.tsx | 29 +++-------- .../LiveStream/nests-participants.tsx | 24 +++++++++ packages/app/src/Hooks/useLiveStreams.ts | 2 +- 4 files changed, 80 insertions(+), 25 deletions(-) create mode 100644 packages/app/src/Components/LiveStream/nests-participants.tsx diff --git a/packages/app/src/Components/LiveStream/LiveStreams.tsx b/packages/app/src/Components/LiveStream/LiveStreams.tsx index 62613f92..b6b62e6f 100644 --- a/packages/app/src/Components/LiveStream/LiveStreams.tsx +++ b/packages/app/src/Components/LiveStream/LiveStreams.tsx @@ -10,6 +10,7 @@ import useLiveStreams from "@/Hooks/useLiveStreams"; import { findTag } from "@/Utils"; import Avatar from "../User/Avatar"; +import { NestsParticipants } from "./nests-participants"; export function LiveStreams() { const streams = useLiveStreams(); @@ -17,9 +18,18 @@ export function LiveStreams() { return (
- {streams.map(v => ( - - ))} + {streams.map(v => { + const k = `${v.kind}:${v.pubkey}:${findTag(v, "d")}`; + const isVideoStream = v.tags.some(a => a[0] === "streaming" && a[1].includes(".m3u8")); + if (isVideoStream) { + return ; + } + + const isNests = v.tags.some(a => a[0] === "streaming" && a[1].startsWith("wss+livekit://")); + if (isNests) { + return ; + } + })}
); } @@ -66,3 +76,37 @@ export function LiveStreamEvent({ ev, className }: { ev: NostrEvent; className?: ); } + +export function AudioRoom({ ev, className }: { ev: NostrEvent; className?: string }) { + const { proxy } = useImgProxy(); + const title = findTag(ev, "title"); + const image = findTag(ev, "image"); + + const link = NostrLink.fromEvent(ev).encode(); + const imageProxy = proxy(image ?? ""); + + return ( + +
+
+
+ +
+
+
+
+ {title} +
+
+
+ + ); +} diff --git a/packages/app/src/Components/LiveStream/livekit.tsx b/packages/app/src/Components/LiveStream/livekit.tsx index 2fcb6b00..97c87bd1 100644 --- a/packages/app/src/Components/LiveStream/livekit.tsx +++ b/packages/app/src/Components/LiveStream/livekit.tsx @@ -6,7 +6,7 @@ import { useParticipantPermissions, useParticipants, } from "@livekit/components-react"; -import { dedupe, unixNow } from "@snort/shared"; +import { unixNow } from "@snort/shared"; import { EventKind, EventPublisher, NostrLink, RequestBuilder, SystemInterface, TaggedNostrEvent } from "@snort/system"; import { useRequestBuilder, useUserProfile } from "@snort/system-react"; import classNames from "classnames"; @@ -22,9 +22,9 @@ import AsyncButton from "../Button/AsyncButton"; import IconButton from "../Button/IconButton"; import { ProxyImg } from "../ProxyImg"; import Avatar from "../User/Avatar"; -import { AvatarGroup } from "../User/AvatarGroup"; import DisplayName from "../User/DisplayName"; import ProfileImage from "../User/ProfileImage"; +import { NestsParticipants } from "./nests-participants"; import VuBar from "./VU"; enum RoomTab { @@ -116,11 +116,15 @@ function RoomHeader({ ev }: { ev: TaggedNostrEvent }) { const { image, title } = extractStreamInfo(ev); return (
- {image ? :
} + {image ? ( + + ) : ( +
+ )}
{title}
- +
@@ -287,23 +291,6 @@ function WriteChatMessage({ ev }: { ev: TaggedNostrEvent }) { ); } -function NostrParticipants({ ev }: { ev: TaggedNostrEvent }) { - const link = NostrLink.fromEvent(ev); - const sub = useMemo(() => { - const sub = new RequestBuilder(`livekit-participants:${link.tagKey}`); - sub - .withFilter() - .replyToLink([link]) - .kinds([10_312 as EventKind]) - .since(unixNow() - 600); - return sub; - }, [link.tagKey]); - - const presense = useRequestBuilder(sub); - const filteredPresence = presense.filter(ev => ev.created_at > unixNow() - 600); - return a.pubkey))} size={32} />; -} - function LiveKitUser({ p }: { p: RemoteParticipant | LocalParticipant }) { const pubkey = p.identity.startsWith("guest-") ? "anon" : p.identity; const profile = useUserProfile(pubkey); diff --git a/packages/app/src/Components/LiveStream/nests-participants.tsx b/packages/app/src/Components/LiveStream/nests-participants.tsx new file mode 100644 index 00000000..b4c6407f --- /dev/null +++ b/packages/app/src/Components/LiveStream/nests-participants.tsx @@ -0,0 +1,24 @@ +import { dedupe, unixNow } from "@snort/shared"; +import { EventKind, NostrLink, RequestBuilder, TaggedNostrEvent } from "@snort/system"; +import { useRequestBuilder } from "@snort/system-react"; +import { useMemo } from "react"; + +import { AvatarGroup } from "../User/AvatarGroup"; + +export function NestsParticipants({ ev }: { ev: TaggedNostrEvent }) { + const link = NostrLink.fromEvent(ev); + const sub = useMemo(() => { + const sub = new RequestBuilder(`livekit-participants:${link.tagKey}`); + sub.withOptions({ leaveOpen: true }); + sub + .withFilter() + .replyToLink([link]) + .kinds([10_312 as EventKind]) + .since(unixNow() - 600); + return sub; + }, [link.tagKey]); + + const presense = useRequestBuilder(sub); + const filteredPresence = presense.filter(ev => ev.created_at > unixNow() - 600); + return a.pubkey)).slice(0, 5)} size={32} />; +} diff --git a/packages/app/src/Hooks/useLiveStreams.ts b/packages/app/src/Hooks/useLiveStreams.ts index d117f157..61e36b25 100644 --- a/packages/app/src/Hooks/useLiveStreams.ts +++ b/packages/app/src/Hooks/useLiveStreams.ts @@ -11,7 +11,7 @@ export default function useLiveStreams() { const rb = new RequestBuilder("streams"); rb.withFilter() .kinds([EventKind.LiveEvent]) - .since(unixNow() - Hour); + .since(unixNow() - 4 * Hour); return rb; }, []);