From 39c8b3dfe420e1c22f010d28ce2701a9ec7504b4 Mon Sep 17 00:00:00 2001 From: Gigi Date: Thu, 16 Oct 2025 22:45:56 +0200 Subject: [PATCH] fix: auto-clear old bunker accounts that were created with wrong setup - Old bunker accounts were created before proper method binding - Add version check to clear nostr-connect accounts once - Preserves extension accounts - Users will need to reconnect bunker (one-time migration) --- src/App.tsx | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 5a33a871..3dd53db2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -203,13 +203,27 @@ function App() { try { const accountsJson = localStorage.getItem('accounts') if (accountsJson) { - await accounts.fromJSON(JSON.parse(accountsJson)) - } - - // Restore active account - const activeId = localStorage.getItem('active') - if (activeId && accounts.getAccount(activeId)) { - accounts.setActive(activeId) + const parsed = JSON.parse(accountsJson) + + // Clear old bunker accounts (they were created with wrong setup) + const bunkerFixVersion = localStorage.getItem('bunkerFixVersion') + if (bunkerFixVersion !== '1') { + console.log('[bunker] Clearing old bunker accounts (need to reconnect with fixed setup)') + const nonBunkerAccounts = parsed.filter((acc: any) => acc.type !== 'nostr-connect') + if (nonBunkerAccounts.length > 0) { + await accounts.fromJSON(nonBunkerAccounts) + } + localStorage.setItem('bunkerFixVersion', '1') + localStorage.removeItem('active') + } else { + await accounts.fromJSON(parsed) + + // Restore active account + const activeId = localStorage.getItem('active') + if (activeId && accounts.getAccount(activeId)) { + accounts.setActive(activeId) + } + } } } catch (err) { console.error('[bunker] Failed to restore accounts:', err)