fix: create and setup pool BEFORE loading accounts from localStorage

- NostrConnectAccount.fromJSON needs NostrConnectSigner.pool to be set
- Move pool creation and setup before accounts.fromJSON()
- This fixes 'Missing subscriptionMethod' error on page reload
- Now bunker accounts can be properly restored from localStorage
This commit is contained in:
Gigi
2025-10-16 22:25:15 +02:00
parent 5229e45566
commit d2f2b689f9

View File

@@ -188,6 +188,16 @@ function App() {
// Register common account types (needed for deserialization)
registerCommonAccountTypes(accounts)
// Create relay pool and set it up BEFORE loading accounts
// NostrConnectAccount.fromJSON needs this to restore the signer
const pool = new RelayPool()
NostrConnectSigner.pool = pool
console.log('[bunker] ✅ Pool assigned to NostrConnectSigner (before account load)')
// Create a relay group for better event deduplication and management
pool.group(RELAYS)
console.log('[bunker] Created relay group with', RELAYS.length, 'relays (including local)')
// Load persisted accounts from localStorage
try {
const accountsJson = localStorage.getItem('accounts')
@@ -235,17 +245,6 @@ function App() {
}
})
const pool = new RelayPool()
// Setup NostrConnectSigner to use the relay pool FIRST before any reconnections
NostrConnectSigner.pool = pool
console.log('[bunker] ✅ Pool assigned to NostrConnectSigner')
// Create a relay group for better event deduplication and management
pool.group(RELAYS)
console.log('Created relay group with', RELAYS.length, 'relays (including local)')
console.log('Relay URLs:', RELAYS)
// Reconnect bunker signers when active account changes
// Keep track of which accounts we've already reconnected to avoid double-connecting
const reconnectedAccounts = new Set<string>()