mirror of
https://github.com/dergigi/boris.git
synced 2025-12-28 20:14:36 +01:00
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)
This commit is contained in:
28
src/App.tsx
28
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)
|
||||
|
||||
Reference in New Issue
Block a user