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
This commit is contained in:
Claude
2026-01-20 12:00:57 +00:00
parent 1ed8b8a6b6
commit ef02f4a379
2 changed files with 17 additions and 33 deletions

View File

@@ -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 {

View File

@@ -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(() => {