fix: Settings stores the URL on screen when another page stored a different one (closes #688)
The RPC and Blockscout "Save" buttons in Settings now set the URL in the stored record, inside the save. Before this change, the save wrote only fields that differed from what the page last saved. If another page stored a different URL for the same network, a "Save" of the URL this page loaded left the other page's URL stored, and the flash still read "Saved.". The save still refuses a URL when the active network is no longer the one Settings showed. Model: opus-5-5
This commit was merged in pull request #694.
This commit is contained in:
@@ -334,6 +334,11 @@ function showNewSettings() {
|
||||
// src/popup/index.js) between setting the URL and writing it. If the active
|
||||
// network is no longer `networkId`, on this page or in the stored record,
|
||||
// nothing is saved. The flash message then says that the network changed.
|
||||
//
|
||||
// The save writes only the fields that differ from what this page last saved.
|
||||
// Another page may have stored a different URL since then. So `url` is set in
|
||||
// the stored record too. "Saved." then means that the stored record holds
|
||||
// `url`.
|
||||
async function saveEndpoint(field, url, networkId) {
|
||||
let refused = false;
|
||||
await saveState((stored) => {
|
||||
@@ -341,6 +346,7 @@ async function saveEndpoint(field, url, networkId) {
|
||||
state.networkId !== networkId || stored.networkId !== networkId;
|
||||
if (refused) return false;
|
||||
state[field] = url;
|
||||
stored[field] = url;
|
||||
});
|
||||
if (refused) {
|
||||
showFlash("The URL was not saved because the network changed.");
|
||||
|
||||
Reference in New Issue
Block a user