Choosing another endpoint in settings updated balances only eventually. Three
things were wrong:
- The popup read the endpoint only when it rendered. Changing the setting
didn't re-render the popup, so the switch waited for some unrelated update.
- The old subscription was never ended. Each switch added a subscription
beside the old one, and whichever endpoint the background connected to last
won.
- The custom-node field saved every keystroke. Once the switch is immediate,
that means connecting to `w`, `ws`, `ws:`, and so on.
Now:
- the balance hook follows the setting, including a change made in another
extension page;
- it clears balances at once, rather than showing another chain's while the
new one loads;
- it ends the old subscription through a new pri(balances.unsubscribe);
- the background shares one in-flight connection, and discards a connection or
read that a later choice has superseded;
- a typed endpoint is used on Enter or when the field loses focus.
Verified in Firefox against the live nodes, with crystal_alice imported:
- mainnet -> Heisenberg shows 477.325 HEI after 1.5s;
- Heisenberg -> Planck shows 0 PLK after 0.4s;
- Planck -> mainnet shows 0 QTC after 1.0s;
- each switch clears the old balance within 0.1s;
- typing a node address leaves the saved endpoint unchanged until blur.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012uDUodEcRbBwNRi3UCmw8f