From 6188445d03bffc11b7fc672ec5a9e7415b9d59a6 Mon Sep 17 00:00:00 2001
From: Keep Creating Online
✓ Found on ${stats.latestVerified.count} relays
+✓ Found on ${stats.latestVerified.count} relay(s):
+${stats.latestVerified.relays.join('\n')}
`; } @@ -716,13 +726,16 @@ function initializeBroadcast() { results.verified.forEach(verifyGroup => { if (verifyGroup.value) { - const successfulVerifications = verifyGroup.value.filter(v => v.success).length; - stats.verifiedCount += successfulVerifications; + // Count successful verifications across all relays + const successfulRelays = verifyGroup.value.filter(v => v.success); + stats.verifiedCount += successfulRelays.length; - if (successfulVerifications > 0) { + if (successfulRelays.length > 0) { + // Store both the event ID and the specific relays it was found on stats.latestVerified = { eventId: verifyGroup.value[0].eventId, - count: successfulVerifications + count: successfulRelays.length, + relays: successfulRelays.map(v => v.relay) }; } } @@ -758,6 +771,7 @@ function initializeBroadcast() { `; } finally { startButton.disabled = false; + pool.close(); } }); @@ -805,11 +819,31 @@ async function broadcastSingleEvent(event, buttonElement) { const pool = new NostrTools.SimplePool(); const verificationResults = []; + const publishResults = []; try { - const publishResult = await pool.publish(broadcastRelays, event); + // Publish to each relay individually and track results + for (const relay of broadcastRelays) { + try { + const published = await pool.publish([relay], event); + publishResults.push({ + relay, + success: true, + published + }); + } catch (err) { + console.error(`Failed to publish to ${relay}:`, err); + publishResults.push({ + relay, + success: false, + error: err.message + }); + } + } - if (publishResult) { + const anySuccessfulPublish = publishResults.some(r => r.success); + + if (anySuccessfulPublish) { await new Promise(resolve => setTimeout(resolve, 2000)); // Wait 2 seconds buttonElement.textContent = 'Verifying...'; @@ -825,6 +859,7 @@ async function broadcastSingleEvent(event, buttonElement) { const nostrBandLink = `https://nostr.band/event/${event.id}`; let message = `Event ID ${event.id} broadcast complete!\n\n`; + message += `Successfully published to ${publishResults.filter(r => r.success).length}/${broadcastRelays.length} relays\n`; message += `Found on ${foundOn.length} relay(s):\n${foundOn.join('\n')}\n\n`; message += `View on nostr.band: ${nostrBandLink}`; @@ -841,7 +876,8 @@ async function broadcastSingleEvent(event, buttonElement) { // Log detailed results to console for debugging console.log('Verification Results:', { eventId: event.id, - results: verificationResults + publish: publishResults, + verify: verificationResults }); } else { alert(`Event ID ${event.id} failed to broadcast to any relays.`); @@ -852,6 +888,7 @@ async function broadcastSingleEvent(event, buttonElement) { } finally { buttonElement.disabled = false; buttonElement.textContent = 'Broadcast'; + pool.close(); } }