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

@@ -44,6 +44,10 @@ undefined identifiers, which is how
# Completed Steps
- 2026-08-11: Wallet deletion repairs its own state — `hasWallet` follows the
remaining wallets, the selection only moves when it was deleted, and the
active-address change is broadcast to connected sites
([#156](https://git.eeqj.de/sneak/AutistMask/issues/156)).
- 2026-08-11: `TODO.md` Workflow rewritten to the branch-and-PR-per-issue model
on `next`, with Status and Next Step refreshed
([#191](https://git.eeqj.de/sneak/AutistMask/issues/191)).