mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-06-16 17:48:34 +02:00
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:
@@ -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 {
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user