feat: publish chat to stream event relays

This commit is contained in:
2024-11-22 14:48:30 +00:00
parent aa7aca8823
commit d201683689
3 changed files with 11 additions and 2 deletions

View File

@ -224,7 +224,11 @@ export function LiveChat({
{(canWrite ?? true) && (
<div className="flex gap-2 border-t py-2 border-layer-1">
{login ? (
<WriteMessage emojiPacks={allEmojiPacks} link={link} />
<WriteMessage
emojiPacks={allEmojiPacks}
link={link}
relays={ev?.tags.filter(a => a[0] === "relays").map(a => a[1])}
/>
) : (
<p>
<FormattedMessage defaultMessage="Please login to write messages!" id="RXQdxR" />

View File

@ -16,10 +16,12 @@ export function WriteMessage({
link,
emojiPacks,
kind,
relays,
}: {
link: NostrLink;
emojiPacks: EmojiPack[];
kind?: EventKind;
relays?: Array<string>;
}) {
const system = useContext(SnortContext);
const ref = useRef<HTMLDivElement | null>(null);
@ -61,6 +63,9 @@ export function WriteMessage({
if (reply) {
console.debug(reply);
system.BroadcastEvent(reply);
for (const r of relays ?? []) {
system.WriteOnceToRelay(r, reply);
}
}
setChat("");
}

View File

@ -56,7 +56,7 @@ export function StreamPage({ link, evPreload }: { evPreload?: TaggedNostrEvent;
</Helmet>
<div className="flex flex-col gap-2 xl:overflow-y-auto scrollbar-hidden">
<Suspense>
{ev?.kind === LIVE_STREAM && (
{ev?.kind === LIVE_STREAM && evLink && (
<LiveVideoPlayer
title={title}
stream={status === StreamState.Live ? stream : recording}