diff --git a/src/components/nostr/kinds/BadgeDefinitionDetailRenderer.tsx b/src/components/nostr/kinds/BadgeDefinitionDetailRenderer.tsx index 2be0d45..e0b1ed6 100644 --- a/src/components/nostr/kinds/BadgeDefinitionDetailRenderer.tsx +++ b/src/components/nostr/kinds/BadgeDefinitionDetailRenderer.tsx @@ -8,10 +8,6 @@ import { } from "@/lib/nip58-helpers"; import { UserName } from "../UserName"; import { Award } from "lucide-react"; -import { useMemo } from "react"; -import { useLiveTimeline } from "@/hooks/useLiveTimeline"; -import { getSeenRelays } from "applesauce-core/helpers/relays"; -import { relayListCache } from "@/services/relay-list-cache"; interface BadgeDefinitionDetailRendererProps { event: NostrEvent; @@ -50,8 +46,8 @@ function ImageVariant({ } /** - * Detail renderer for Kind 30009 - Badge Definition (NIP-58) - * Shows comprehensive badge information including all image variants + * Detail renderer for Kind 30009 - Badge (NIP-58) + * Shows badge information including all image variants */ export function BadgeDefinitionDetailRenderer({ event, @@ -65,61 +61,6 @@ export function BadgeDefinitionDetailRenderer({ // Use name if available, fallback to identifier const displayTitle = name || identifier || "Badge"; - // Build relay list for fetching badge awards (kind 8) - const relays = useMemo(() => { - const relaySet = new Set(); - - // Add seen relays from the badge definition event - const seenRelays = getSeenRelays(event); - if (seenRelays) { - for (const relay of seenRelays) { - relaySet.add(relay); - } - } - - // Add issuer's outbox relays - const outboxRelays = relayListCache.getOutboxRelaysSync(event.pubkey); - if (outboxRelays) { - for (const relay of outboxRelays.slice(0, 3)) { - relaySet.add(relay); - } - } - - return Array.from(relaySet); - }, [event]); - - // Query for awards (kind 8) that reference this badge definition - const awardsFilter = useMemo(() => { - if (!identifier) { - return { kinds: [8], ids: [] }; // No match if no identifier - } - return { - kinds: [8], - "#a": [`30009:${event.pubkey}:${identifier}`], - }; - }, [event.pubkey, identifier]); - - // Fetch awards from relays - const { events: awards } = useLiveTimeline( - `badge-awards-${event.id}`, - awardsFilter, - relays, - { limit: 100 }, - ); - - // Count unique recipients - const uniqueRecipients = useMemo(() => { - if (!awards || awards.length === 0) return 0; - const recipients = new Set(); - for (const award of awards) { - const pTags = award.tags.filter((tag) => tag[0] === "p" && tag[1]); - for (const pTag of pTags) { - recipients.add(pTag[1]); - } - } - return recipients.size; - }, [awards]); - return (
{/* Header Section */} @@ -164,26 +105,6 @@ export function BadgeDefinitionDetailRenderer({
)} - - {/* Awards Count */} - {awards && awards.length > 0 && ( -
-

Times Awarded

- - {awards.length} award{awards.length !== 1 ? "s" : ""} - -
- )} - - {/* Recipients Count */} - {uniqueRecipients > 0 && ( -
-

Recipients

- - {uniqueRecipients} user{uniqueRecipients !== 1 ? "s" : ""} - -
- )} {/* Image Variants Section */} @@ -209,18 +130,6 @@ export function BadgeDefinitionDetailRenderer({ )} - - {/* Award Address for Reference */} - {identifier && ( -
-

- Badge Address (for awarding) -

- - 30009:{event.pubkey}:{identifier} - -
- )} ); } diff --git a/src/components/nostr/kinds/BadgeDefinitionRenderer.tsx b/src/components/nostr/kinds/BadgeDefinitionRenderer.tsx index 8dcec5e..7b29420 100644 --- a/src/components/nostr/kinds/BadgeDefinitionRenderer.tsx +++ b/src/components/nostr/kinds/BadgeDefinitionRenderer.tsx @@ -7,61 +7,35 @@ import { getBadgeIdentifier, getBadgeName, getBadgeDescription, - getBadgeImageUrl, } from "@/lib/nip58-helpers"; -import { Award } from "lucide-react"; /** - * Renderer for Kind 30009 - Badge Definition (NIP-58) - * Clean feed view with badge image, name, and description + * Renderer for Kind 30009 - Badge (NIP-58) + * Simple feed view with name and description */ export function BadgeDefinitionRenderer({ event }: BaseEventProps) { const identifier = getBadgeIdentifier(event); const name = getBadgeName(event); const description = getBadgeDescription(event); - const imageUrl = getBadgeImageUrl(event); // Use name if available, fallback to identifier const displayTitle = name || identifier || "Badge"; return ( -
- {/* Badge Image */} - {imageUrl ? ( - {displayTitle} - ) : ( -
- -
+
+ + {displayTitle} + + + {description && ( +

+ {description} +

)} - - {/* Badge Info */} -
- - {displayTitle} - - - {description && ( -

- {description} -

- )} - - {identifier && ( - - {identifier} - - )} -
); diff --git a/src/components/nostr/kinds/index.tsx b/src/components/nostr/kinds/index.tsx index 7cd07ca..f3de435 100644 --- a/src/components/nostr/kinds/index.tsx +++ b/src/components/nostr/kinds/index.tsx @@ -202,7 +202,7 @@ const kindRenderers: Record> = { 30005: VideoCurationSetRenderer, // Video Curation Sets (NIP-51) 30006: PictureCurationSetRenderer, // Picture Curation Sets (NIP-51) 30007: KindMuteSetRenderer, // Kind Mute Sets (NIP-51) - 30009: BadgeDefinitionRenderer, // Badge Definition (NIP-58) + 30009: BadgeDefinitionRenderer, // Badge (NIP-58) 30015: InterestSetRenderer, // Interest Sets (NIP-51) 30023: Kind30023Renderer, // Long-form Article 30030: EmojiSetRenderer, // Emoji Sets (NIP-30) @@ -296,7 +296,7 @@ const detailRenderers: Record< 30005: VideoCurationSetDetailRenderer, // Video Curation Sets Detail (NIP-51) 30006: PictureCurationSetDetailRenderer, // Picture Curation Sets Detail (NIP-51) 30007: KindMuteSetDetailRenderer, // Kind Mute Sets Detail (NIP-51) - 30009: BadgeDefinitionDetailRenderer, // Badge Definition Detail (NIP-58) + 30009: BadgeDefinitionDetailRenderer, // Badge Detail (NIP-58) 30015: InterestSetDetailRenderer, // Interest Sets Detail (NIP-51) 30023: Kind30023DetailRenderer, // Long-form Article Detail 30030: EmojiSetDetailRenderer, // Emoji Sets Detail (NIP-30)