From 59dac947abc11d38fd0445b56d46fe784cea9a8b Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 17 Oct 2025 00:00:57 +0200 Subject: [PATCH] fix: actually reorder bunker relay addition before signer recreation - Previous commit had wrong message, code wasn't actually changed - Now properly add relays to pool before creating NostrConnectSigner - Ensures publishMethod/subscriptionMethod have full relay list available --- src/App.tsx | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index d585e9c9..7eb1425a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -276,6 +276,20 @@ function App() { // For restored signers, ensure they have the pool's subscription methods // The signer was created in fromJSON without pool context, so we need to recreate it const signerData = nostrConnectAccount.toJSON().signer + + // Add bunker's relays to the pool BEFORE recreating the signer + // This ensures the pool has all relays when the signer sets up its methods + const bunkerRelays = signerData.relays || [] + const existingRelayUrls = new Set(Array.from(pool.relays.keys())) + const newBunkerRelays = bunkerRelays.filter(url => !existingRelayUrls.has(url)) + + if (newBunkerRelays.length > 0) { + console.log('[bunker] Adding bunker relays to pool BEFORE signer recreation:', newBunkerRelays) + pool.group(newBunkerRelays) + } else { + console.log('[bunker] Bunker relays already in pool') + } + const recreatedSigner = new NostrConnectSigner({ relays: signerData.relays, pubkey: nostrConnectAccount.pubkey, @@ -288,18 +302,6 @@ function App() { nostrConnectAccount.signer = recreatedSigner console.log('[bunker] ✅ Signer recreated with pool context') - // Add bunker's relays to the pool so signing requests can be sent/received - const bunkerRelays = nostrConnectAccount.signer.relays || [] - const existingRelayUrls = new Set(Array.from(pool.relays.keys())) - const newBunkerRelays = bunkerRelays.filter(url => !existingRelayUrls.has(url)) - - if (newBunkerRelays.length > 0) { - console.log('[bunker] Adding new bunker relays to pool:', newBunkerRelays) - pool.group(newBunkerRelays) - } else { - console.log('[bunker] Bunker relays already in pool') - } - // Just ensure the signer is listening for responses - don't call connect() again // The fromBunkerURI already connected with permissions during login if (!nostrConnectAccount.signer.listening) {