feat: read chat/zaps from stream event relays tags
This commit is contained in:
parent
d201683689
commit
aa56d475a0
@ -2,7 +2,7 @@ import "./live-chat.css";
|
|||||||
import { FormattedMessage } from "react-intl";
|
import { FormattedMessage } from "react-intl";
|
||||||
import { EventKind, NostrEvent, NostrLink, NostrPrefix, ParsedZap, TaggedNostrEvent } from "@snort/system";
|
import { EventKind, NostrEvent, NostrLink, NostrPrefix, ParsedZap, TaggedNostrEvent } from "@snort/system";
|
||||||
import { useEventFeed, useEventReactions, useReactions, useUserProfile } from "@snort/system-react";
|
import { useEventFeed, useEventReactions, useReactions, useUserProfile } from "@snort/system-react";
|
||||||
import { removeUndefined, unixNow, unwrap } from "@snort/shared";
|
import { dedupe, removeUndefined, sanitizeRelayUrl, unixNow, unwrap } from "@snort/shared";
|
||||||
import { useEffect, useMemo } from "react";
|
import { useEffect, useMemo } from "react";
|
||||||
|
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
@ -69,14 +69,17 @@ export function LiveChat({
|
|||||||
className?: string;
|
className?: string;
|
||||||
autoRaid?: boolean;
|
autoRaid?: boolean;
|
||||||
}) {
|
}) {
|
||||||
|
const relays = dedupe(removeUndefined(ev?.tags.filter(a => a[0] === "relays").map(a => sanitizeRelayUrl(a[1])) ?? []));
|
||||||
const host = getHost(ev);
|
const host = getHost(ev);
|
||||||
const feed = useReactions(
|
const feed = useReactions(
|
||||||
`live:${link?.id}:${link?.author}:reactions`,
|
`live:${link?.id}:${link?.author}:reactions`,
|
||||||
goal ? [link, NostrLink.fromEvent(goal)] : [link],
|
goal ? [link, NostrLink.fromEvent(goal)] : [link],
|
||||||
rb => {
|
rb => {
|
||||||
if (link) {
|
if (link) {
|
||||||
const aTag = `${link.kind}:${link.author}:${link.id}`;
|
rb.withFilter().kinds([LIVE_STREAM_CHAT, LIVE_STREAM_RAID, LIVE_STREAM_CLIP])
|
||||||
rb.withFilter().kinds([LIVE_STREAM_CHAT, LIVE_STREAM_RAID, LIVE_STREAM_CLIP]).tag("a", [aTag]).limit(200);
|
.replyToLink([link])
|
||||||
|
.relay(relays)
|
||||||
|
.limit(200);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
@ -227,7 +230,7 @@ export function LiveChat({
|
|||||||
<WriteMessage
|
<WriteMessage
|
||||||
emojiPacks={allEmojiPacks}
|
emojiPacks={allEmojiPacks}
|
||||||
link={link}
|
link={link}
|
||||||
relays={ev?.tags.filter(a => a[0] === "relays").map(a => a[1])}
|
relays={relays}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<p>
|
<p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user