This commit is contained in:
2023-08-28 15:07:59 +01:00
parent 9bbbd513c2
commit b5033798c4
21 changed files with 427 additions and 103 deletions

View File

@ -1,30 +1,8 @@
import { useMemo } from "react";
import {
EventKind,
NostrEvent,
RequestBuilder,
NoteCollection,
ReplaceableNoteStore,
NostrLink,
parseZap,
} from "@snort/system";
import { RequestBuilder, ReplaceableNoteStore, NostrLink } from "@snort/system";
import { useRequestBuilder } from "@snort/system-react";
import { unwrap } from "@snort/shared";
import { GOAL } from "const";
import { System } from "index";
export function useZaps(goal: NostrEvent, leaveOpen = false) {
const sub = useMemo(() => {
const b = new RequestBuilder(`goal-zaps:${goal.id.slice(0, 12)}`);
b.withOptions({ leaveOpen });
b.withFilter().kinds([EventKind.ZapReceipt]).tag("e", [goal.id]).since(goal.created_at);
return b;
}, [goal, leaveOpen]);
const { data } = useRequestBuilder(NoteCollection, sub);
return data?.map(ev => parseZap(ev, System.ProfileLoader.Cache)).filter(z => z && z.valid) ?? [];
}
export function useZapGoal(host: string, link?: NostrLink, leaveOpen = false) {
const sub = useMemo(() => {