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. The save writes only the fields that differ from what the page last saved. Before this change, a "Save" of the URL that this page loaded kept another page's different URL stored. Before this change, the flash message for that save read "Saved.". A save refused because the network changed still stores nothing. Model: opus-5-5
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