From 986b44b7b60ac90f6f595a3530df5f467b74d1a4 Mon Sep 17 00:00:00 2001 From: Alejandro Gomez Date: Thu, 6 Jul 2023 21:46:59 +0200 Subject: [PATCH] fix: filter goals by host --- src/element/new-goal.tsx | 3 +++ src/hooks/goals.ts | 7 ++++--- src/pages/stream-page.tsx | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/element/new-goal.tsx b/src/element/new-goal.tsx index 2c6050c..898a7ae 100644 --- a/src/element/new-goal.tsx +++ b/src/element/new-goal.tsx @@ -29,6 +29,9 @@ export function NewGoalDialog({ link }: NewGoalDialogProps) { .tag(["a", `${link.kind}:${link.author}:${link.id}`]) .tag(["amount", String(Number(goalAmount) * 1000)]) .content(goalName); + if (link.relays?.length) { + eb.tag(["relays", ...link.relays]); + } return eb; }); console.debug(evNew); diff --git a/src/hooks/goals.ts b/src/hooks/goals.ts index fab629e..0e25018 100644 --- a/src/hooks/goals.ts +++ b/src/hooks/goals.ts @@ -11,15 +11,16 @@ import { GOAL } from "const"; import { System } from "index"; import { findTag } from "utils"; -export function useZapGoal(link: NostrLink, leaveOpen = false) { +export function useZapGoal(host: string, link: NostrLink, leaveOpen = false) { const sub = useMemo(() => { - const b = new RequestBuilder(`goals:${link.author!.slice(0, 12)}`); + const b = new RequestBuilder(`goals:${host.slice(0, 12)}`); b.withOptions({ leaveOpen }); b.withFilter() .kinds([GOAL]) + .authors([host]) .tag("a", [`${link.kind}:${link.author!}:${link.id}`]); return b; - }, [link]); + }, [link, leaveOpen]); const { data } = useRequestBuilder( System, diff --git a/src/pages/stream-page.tsx b/src/pages/stream-page.tsx index 17aaf0f..47e8671 100644 --- a/src/pages/stream-page.tsx +++ b/src/pages/stream-page.tsx @@ -108,7 +108,8 @@ export function StreamPage() { const params = useParams(); const link = parseNostrLink(params.id!); const { data: ev } = useEventFeed(link, true); - const goal = useZapGoal(link, true); + const host = getHost(ev); + const goal = useZapGoal(host, link, true); return ( <>