diff --git a/src/lib/nostr/client.ts b/src/lib/nostr/client.ts index dad7531..87d02bb 100644 --- a/src/lib/nostr/client.ts +++ b/src/lib/nostr/client.ts @@ -75,19 +75,25 @@ export class NostrClient { ] try { - // Get events from all relays using the working get() method - const noteEvents = await Promise.all( - this.relays.map(async (relay) => { - try { - const filter = filters[0] - const singleEvent = await this.pool.get([relay], filter) - return singleEvent ? [singleEvent] : [] - } catch (error) { - console.warn(`Failed to fetch notes from relay ${relay}:`, error) - return [] - } - }) - ) + // Use proper subscription method to get multiple events + const allEvents: Event[] = [] + + const subscription = this.pool.subscribeMany(this.relays, filters, { + onevent(event: Event) { + allEvents.push(event) + }, + oneose() { + // End of stored events - subscription is complete for initial fetch + } + }) + + // Wait for events to be collected (give it time to get all stored events) + await new Promise(resolve => setTimeout(resolve, 2000)) + + // Close the subscription since we just want the initial fetch + subscription.close() + + const noteEvents = [allEvents] // Wrap in array to match expected format // Flatten and deduplicate events by ID const uniqueNotes = Array.from(