diff --git a/src/element/live-chat.tsx b/src/element/live-chat.tsx
index 9de8f25..6525c81 100644
--- a/src/element/live-chat.tsx
+++ b/src/element/live-chat.tsx
@@ -66,7 +66,7 @@ export function LiveChat({
height?: number;
}) {
const host = getHost(ev);
- const feed = useLiveChatFeed(link, host);
+ const feed = useLiveChatFeed(link, goal ? [goal.id] : undefined);
const login = useLogin();
useEffect(() => {
const pubkeys = [
@@ -81,7 +81,7 @@ export function LiveChat({
.filter((z) => z && z.valid);
const goalZaps = feed.zaps
- .filter((ev) => (goal ? ev.created_at > goal.created_at : false))
+ .filter((ev) => (goal ? ev.created_at > goal.created_at && ev.tags.some(t => t[0] === "e" && t[1] === goal.id) : false))
.map((ev) => parseZap(ev, System.ProfileLoader.Cache))
.filter((z) => z && z.valid);
@@ -124,7 +124,7 @@ export function LiveChat({
- {goal && }
+ {goal && }
{login?.pubkey === streamer && }
)}
diff --git a/src/hooks/live-chat.tsx b/src/hooks/live-chat.tsx
index dca8ab2..96ab990 100644
--- a/src/hooks/live-chat.tsx
+++ b/src/hooks/live-chat.tsx
@@ -5,24 +5,26 @@ import {
FlatNoteStore,
} from "@snort/system";
import { useRequestBuilder } from "@snort/system-react";
+import { unixNow } from "@snort/shared";
import { System } from "index";
import { useMemo } from "react";
import { LIVE_STREAM_CHAT } from "const";
-export function useLiveChatFeed(link: NostrLink, host?: string) {
+export function useLiveChatFeed(link: NostrLink, eZaps?: Array) {
const sub = useMemo(() => {
const rb = new RequestBuilder(`live:${link.id}:${link.author}`);
rb.withOptions({
leaveOpen: true,
});
+ const zapsSince = unixNow() - (60 * 60 * 24 * 7); // 7-days of zaps
const aTag = `${link.kind}:${link.author}:${link.id}`;
rb.withFilter().kinds([LIVE_STREAM_CHAT]).tag("a", [aTag]).limit(100);
- rb.withFilter().kinds([EventKind.ZapReceipt]).tag("a", [aTag]);
- if (host) {
- rb.withFilter().kinds([EventKind.ZapReceipt]).tag("p", [host]);
+ rb.withFilter().kinds([EventKind.ZapReceipt]).tag("a", [aTag]).since(zapsSince);
+ if (eZaps) {
+ rb.withFilter().kinds([EventKind.ZapReceipt]).tag("e", eZaps);
}
return rb;
- }, [link, host]);
+ }, [link, eZaps]);
const feed = useRequestBuilder(System, FlatNoteStore, sub);