fix: repair wallet state on delete (closes #156)
All checks were successful
check / check (push) Successful in 30s

Deleting a wallet left three defects in the same path:

- `hasWallet` stayed true after the last wallet was deleted, so the next
  popup open rendered Home with "No wallets yet" instead of Welcome. It
  now tracks whether any wallet remains.
- The selection was reset to wallet 0 / address 0 unconditionally.
  `selectedWallet` now follows the splice (decremented when a wallet
  before it is removed), and only falls back to the first remaining
  wallet's first address when the selection itself was deleted;
  `activeAddress` only moves when it belonged to the deleted wallet.
- No `AUTISTMASK_ACTIVE_CHANGED` was sent, so connected sites kept
  reporting a deleted address. The delete path now broadcasts it after
  the state is persisted, whenever the active address actually changed,
  and the background re-emits `accountsChanged` from there.

The transition moved into `src/shared/walletDelete.js` so it can be
tested without a DOM. Site-permission cleanup is unchanged and still
covers every address of an HD wallet.
This commit is contained in:
2026-08-11 12:16:59 +00:00
parent d93eda31a0
commit bcaf0cb1f5
5 changed files with 218 additions and 22 deletions

View File

@@ -980,7 +980,7 @@ Currently supported:
### Wallet Management
- [ ] Delete wallet (with confirmation)
- [x] Delete wallet (with confirmation)
- [ ] Delete address from HD wallet (with confirmation)
- [ ] Show wallet's recovery phrase (requires password)