fix: a network switch in Settings leaves no balance from the previous network stored (closes #653)
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run

A save writes only the fields that differ from what the page last saved. When
the page had last saved a balance of "0", the switch's cleared "0" was no
change. So a balance that the background or another page stored since then
stayed under the new network.

The switch's save now also resets these fields in the stored record it reads:

- every address's balance and token balances;
- the time of the last balance refresh.

Every other field merges as before.

Model: opus-5-5
This commit is contained in:
2026-10-27 08:39:44 +00:00
parent f550d8c8d2
commit 3ff84c6b18
4 changed files with 146 additions and 3 deletions
+4 -2
View File
@@ -591,8 +591,10 @@ function reportSaveFailure(err) {
//
// `beforeWrite`, when given, is called inside the lock with the stored record
// as just read, before this page's state is compared against it. It may change
// `state`, and this save writes that change. When it returns false, nothing is
// written; any other return lets the save go ahead.
// `state`, and this save writes that change. It may also change the stored
// record. A field that this page did not change is then written as
// `beforeWrite` left it. When it returns false, nothing is written; any other
// return lets the save go ahead.
function saveState(beforeWrite) {
const turn = withLock("autistmask", () => saveStateOnce(beforeWrite));
// Every failed save is reported, whether or not the caller awaited this