From 0882425eeab48403a5ca6de3a7f10bd82c762ac9 Mon Sep 17 00:00:00 2001 From: Kieran Date: Tue, 14 Nov 2023 14:46:49 +0000 Subject: [PATCH] fix: badges closes #103 --- src/element/live-chat.tsx | 2 +- src/element/stream-cards.css | 1 + src/hooks/badges.ts | 4 ++-- src/hooks/cards.ts | 5 +++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/element/live-chat.tsx b/src/element/live-chat.tsx index 7dca967..6ec554c 100644 --- a/src/element/live-chat.tsx +++ b/src/element/live-chat.tsx @@ -81,7 +81,7 @@ export function LiveChat({ const reactions = useEventReactions(link, feed.reactions); const events = useMemo(() => { - return [...feed.messages, ...feed.reactions, ...awards].sort((a, b) => b.created_at - a.created_at); + return [...feed.messages, ...feed.reactions, ...awards].filter(a => a.created_at > started).sort((a, b) => b.created_at - a.created_at); }, [feed.messages, feed.reactions, awards]); const filteredEvents = useMemo(() => { diff --git a/src/element/stream-cards.css b/src/element/stream-cards.css index ad7d5a9..926168a 100644 --- a/src/element/stream-cards.css +++ b/src/element/stream-cards.css @@ -48,6 +48,7 @@ gap: 16px; flex: 1; width: 100%; + overflow-wrap: break-word; } .stream-card.image-card { diff --git a/src/hooks/badges.ts b/src/hooks/badges.ts index c413fb3..6ed8cf2 100644 --- a/src/hooks/badges.ts +++ b/src/hooks/badges.ts @@ -12,10 +12,10 @@ export function useBadges( leaveOpen = true ): { badges: Badge[]; awards: TaggedNostrEvent[] } { const rb = useMemo(() => { + if (!pubkey) return null; const rb = new RequestBuilder(`badges:${pubkey.slice(0, 12)}`); rb.withOptions({ leaveOpen }); - rb.withFilter().authors([pubkey]).kinds([EventKind.Badge]); - rb.withFilter().authors([pubkey]).kinds([EventKind.BadgeAward]).since(since); + rb.withFilter().authors([pubkey]).kinds([EventKind.Badge, EventKind.BadgeAward]); return rb; }, [pubkey, since]); diff --git a/src/hooks/cards.ts b/src/hooks/cards.ts index 7d5ca34..2c7f307 100644 --- a/src/hooks/cards.ts +++ b/src/hooks/cards.ts @@ -49,9 +49,10 @@ export function useUserCards(pubkey: string, userCards: Array, leaveOp return cards; } -export function useCards(pubkey: string, leaveOpen = false): TaggedNostrEvent[] { +export function useCards(pubkey?: string, leaveOpen = false): TaggedNostrEvent[] { const sub = useMemo(() => { - const b = new RequestBuilder(`user-cards:${pubkey.slice(0, 12)}`); + if (!pubkey) return null; + const b = new RequestBuilder(`user-cards:${pubkey?.slice(0, 12)}`); b.withOptions({ leaveOpen, })