From ef02f4a379220557ece8aa1428522382528e0111 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Jan 2026 12:00:57 +0000 Subject: [PATCH] fix: resolve TypeScript build errors - Remove unused nip19 import from InboxViewer - Simplify InboxRelaysDropdown to use eventStore.getReplaceable directly - Replace use$ with useMemo for better type safety - Build now succeeds without errors --- src/components/InboxViewer.tsx | 1 - src/components/chat/InboxRelaysDropdown.tsx | 49 +++++++-------------- 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/src/components/InboxViewer.tsx b/src/components/InboxViewer.tsx index 403a0f7..a09e881 100644 --- a/src/components/InboxViewer.tsx +++ b/src/components/InboxViewer.tsx @@ -10,7 +10,6 @@ import { useState, useMemo, useEffect } from "react"; import { use$ } from "applesauce-react/hooks"; -import { nip19 } from "nostr-tools"; import { useGrimoire } from "@/core/state"; import { useAccount } from "@/hooks/useAccount"; import { diff --git a/src/components/chat/InboxRelaysDropdown.tsx b/src/components/chat/InboxRelaysDropdown.tsx index b67695c..0c3f052 100644 --- a/src/components/chat/InboxRelaysDropdown.tsx +++ b/src/components/chat/InboxRelaysDropdown.tsx @@ -4,7 +4,6 @@ */ import { useMemo } from "react"; -import { use$ } from "applesauce-react/hooks"; import { Inbox } from "lucide-react"; import { DropdownMenu, @@ -35,42 +34,28 @@ export function InboxRelaysDropdown({ }: InboxRelaysDropdownProps) { const { relays: relayStates } = useRelayState(); - // Get all participant pubkeys - const participantPubkeys = useMemo(() => { - return conversation.participants.map((p) => p.pubkey); - }, [conversation.participants]); - - // Fetch kind 10050 events for all participants - const inboxRelayEvents = use$(() => { - const observables = participantPubkeys.map((pubkey) => - eventStore.replaceable(10050, pubkey, ""), - ); - return observables; - }, [participantPubkeys]); - - // Extract relays from events + // Extract relays from participants' kind 10050 events const participantRelays = useMemo(() => { - if (!inboxRelayEvents) return []; + const results: Array<{ pubkey: string; relays: string[] }> = []; - return participantPubkeys - .map((pubkey, index) => { - const event = inboxRelayEvents[index]; - if (!event) return null; + for (const participant of conversation.participants) { + const event = eventStore.getReplaceable(10050, participant.pubkey, ""); + if (!event) continue; - const relays = event.tags - .filter((t: string[]) => t[0] === "relay" && t[1]) - .map((t: string[]) => t[1]); + const relays = event.tags + .filter((t: string[]) => t[0] === "relay" && t[1]) + .map((t: string[]) => t[1]); - return { - pubkey, + if (relays.length > 0) { + results.push({ + pubkey: participant.pubkey, relays, - }; - }) - .filter( - (p): p is { pubkey: string; relays: string[] } => - p !== null && p.relays.length > 0, - ); - }, [inboxRelayEvents, participantPubkeys]); + }); + } + } + + return results; + }, [conversation.participants]); // Count total relays and connected relays const { totalRelays, connectedCount } = useMemo(() => {