From 0c8054949fed8ddeeadcd25491a33c30e78e47d5 Mon Sep 17 00:00:00 2001 From: Alejandro Gomez Date: Thu, 6 Jul 2023 17:23:49 +0200 Subject: [PATCH] refactor: address review comments --- src/element/live-chat.tsx | 6 +++--- src/hooks/goals.ts | 10 +++++++--- src/pages/stream-page.tsx | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/element/live-chat.tsx b/src/element/live-chat.tsx index b2e22f1..a9f7f05 100644 --- a/src/element/live-chat.tsx +++ b/src/element/live-chat.tsx @@ -4,7 +4,7 @@ import { NostrPrefix, NostrLink, ParsedZap, - TaggedRawEvent, + NostrEvent, parseZap, encodeTLV, } from "@snort/system"; @@ -60,8 +60,8 @@ export function LiveChat({ height, }: { link: NostrLink; - ev?: TaggedRawEvent; - goal?: TaggedRawEvent; + ev?: NostrEvent; + goal?: NostrEvent; options?: LiveChatOptions; height?: number; }) { diff --git a/src/hooks/goals.ts b/src/hooks/goals.ts index 280e0fa..575b403 100644 --- a/src/hooks/goals.ts +++ b/src/hooks/goals.ts @@ -1,7 +1,7 @@ import { useMemo } from "react"; import { RequestBuilder, - FlatNoteStore, + NoteCollection, NostrEvent, EventKind, NostrLink, @@ -11,7 +11,7 @@ import { GOAL } from "const"; import { System } from "index"; import { findTag } from "utils"; -export function useGoal(link: NostrLink, leaveOpen = false) { +export function useZapGoal(link: NostrLink, leaveOpen = false) { const sub = useMemo(() => { const b = new RequestBuilder(`goals:${link.author!.slice(0, 12)}`); b.withOptions({ leaveOpen }); @@ -21,7 +21,11 @@ export function useGoal(link: NostrLink, leaveOpen = false) { return b; }, [link]); - const { data } = useRequestBuilder(System, FlatNoteStore, sub); + const { data } = useRequestBuilder( + System, + NoteCollection, + sub + ); return data?.at(0); } diff --git a/src/pages/stream-page.tsx b/src/pages/stream-page.tsx index 45355a5..11680e2 100644 --- a/src/pages/stream-page.tsx +++ b/src/pages/stream-page.tsx @@ -9,7 +9,7 @@ import { Profile, getName } from "element/profile"; import { LiveChat } from "element/live-chat"; import AsyncButton from "element/async-button"; import { useLogin } from "hooks/login"; -import { useGoal } from "hooks/goals"; +import { useZapGoal } from "hooks/goals"; import { StreamState, System } from "index"; import { SendZapsDialog } from "element/send-zap"; import { NostrEvent } from "@snort/system"; @@ -108,7 +108,7 @@ export function StreamPage() { const params = useParams(); const link = parseNostrLink(params.id!); const { data: ev } = useEventFeed(link, true); - const goal = useGoal(link, true); + const goal = useZapGoal(link, true); return ( <>