fix: a save merges this page's tracked token change into the stored list (closes #717)
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run

A save wrote `trackedTokens` whole, so two pages on one network dropped each
other's adds and brought back each other's removals.

A save that keeps the network now merges this page's change into the stored
list by contract address. A save that switches networks is unchanged.

`mergeTrackedTokens()` does that merge, and the two other merges of tracked
tokens now call it. It keeps one record per contract address, this page's for
a token both lists hold, so a token held twice no longer multiplies.

Model: opus-5-5
This commit was merged in pull request #726.
This commit is contained in:
2026-11-03 05:59:42 +01:00
parent 076726b13d
commit 1a4fb0803d
3 changed files with 194 additions and 26 deletions
+10 -4
View File
@@ -397,10 +397,16 @@ is missing, a write fails.
The popup's `saveState()` (`src/shared/state.js`) reads the stored record,
merges this page's changes into it and writes it back. It writes only the fields
this page changed since its last save. Wallets, site lists and endpoints are
merged entry by entry, so two pages changing different things do not overwrite
each other. The background's `updateState()` reads the record, applies one
change and writes it back.
this page changed since its last save. It merges the fields below entry by
entry, so two pages changing different things do not overwrite each other:
- wallets;
- site lists;
- endpoints;
- tracked tokens.
The background's `updateState()` reads the record, applies one change and writes
it back.
Every write stamps `schemaVersion` with `STATE_SCHEMA_VERSION` from
`src/shared/stateSchema.js`, currently `1`. The version is raised only when the