refactor: upgrade snort libs

This commit is contained in:
2024-01-15 12:22:19 +00:00
parent 0eb9c56442
commit 5c1a143a7d
20 changed files with 97 additions and 198 deletions

View File

@ -1,6 +1,6 @@
import { useMemo } from "react";
import { NoteCollection, ReplaceableNoteStore, RequestBuilder, TaggedNostrEvent } from "@snort/system";
import { RequestBuilder, TaggedNostrEvent } from "@snort/system";
import { useRequestBuilder } from "@snort/system-react";
import { CARD, USER_CARDS } from "@/const";
@ -33,7 +33,7 @@ export function useUserCards(pubkey: string, userCards: Array<string[]>, leaveOp
return rb;
}, [pubkey, related]);
const { data } = useRequestBuilder(NoteCollection, subRelated);
const data = useRequestBuilder(subRelated);
const cards = useMemo(() => {
return related
@ -62,12 +62,12 @@ export function useCards(pubkey?: string, leaveOpen = false): TaggedNostrEvent[]
return b;
}, [pubkey, leaveOpen]);
const { data: userCards } = useRequestBuilder(ReplaceableNoteStore, sub);
const userCards = useRequestBuilder(sub);
const related = useMemo(() => {
// filtering to only show CARD kinds for now, but in the future we could link and render anything
if (userCards) {
return userCards.tags.filter(t => t.at(0) === "a" && t.at(1)?.startsWith(`${CARD}:`));
if (userCards.length > 0) {
return userCards[0].tags.filter(t => t.at(0) === "a" && t.at(1)?.startsWith(`${CARD}:`));
}
return [];
}, [userCards]);
@ -90,7 +90,7 @@ export function useCards(pubkey?: string, leaveOpen = false): TaggedNostrEvent[]
return rb;
}, [pubkey, related]);
const { data } = useRequestBuilder(NoteCollection, subRelated);
const data = useRequestBuilder(subRelated);
const cardEvents = data ?? [];
const cards = useMemo(() => {