Persist navigation state across popup close/reopen
All checks were successful
check / check (push) Successful in 17s
All checks were successful
check / check (push) Successful in 17s
The current view, selected wallet, selected address, and selected token are now saved to extension storage. When the popup reopens, it restores to the last visited view instead of always returning to the home screen. Restorable views: main, address detail, address-token, receive, settings. Non-restorable views (send, confirm, tx status, forms) fall back to the nearest parent. Stored indices are validated against current wallet data to handle stale references. Also refactors receive view setup into a centralized receive.show() function, eliminating duplicate QR/address/warning code from addressDetail.js, addressToken.js, and home.js. Adds settings.show() to centralize settings field population.
This commit is contained in:
@@ -23,7 +23,6 @@ const {
|
||||
const { resolveEnsNames } = require("../../shared/ens");
|
||||
const { updateSendBalance, renderSendTokenSelect } = require("./send");
|
||||
const { log } = require("../../shared/log");
|
||||
const QRCode = require("qrcode");
|
||||
const makeBlockie = require("ethereum-blockies-base64");
|
||||
|
||||
const EXT_ICON =
|
||||
@@ -366,32 +365,7 @@ function init(ctx) {
|
||||
});
|
||||
|
||||
$("btn-address-token-receive").addEventListener("click", () => {
|
||||
const addr = currentAddress();
|
||||
const address = addr ? addr.address : "";
|
||||
$("receive-dot").innerHTML = address ? addressDotHtml(address) : "";
|
||||
$("receive-address").textContent = address;
|
||||
const addrLink = address ? etherscanAddressLink(address) : "";
|
||||
$("receive-etherscan-link").innerHTML = addrLink
|
||||
? `<a href="${addrLink}" target="_blank" rel="noopener" class="inline-flex items-center">${EXT_ICON}</a>`
|
||||
: "";
|
||||
if (address) {
|
||||
QRCode.toCanvas($("receive-qr"), address, {
|
||||
width: 200,
|
||||
margin: 2,
|
||||
color: { dark: "#000000", light: "#ffffff" },
|
||||
});
|
||||
}
|
||||
const warningEl = $("receive-erc20-warning");
|
||||
if (state.selectedToken && state.selectedToken !== "ETH") {
|
||||
warningEl.textContent =
|
||||
"This is an ERC-20 token. Only send " +
|
||||
currentSymbol +
|
||||
" on the Ethereum network to this address. Sending tokens on other networks will result in permanent loss.";
|
||||
warningEl.classList.remove("hidden");
|
||||
} else {
|
||||
warningEl.classList.add("hidden");
|
||||
}
|
||||
showView("receive");
|
||||
ctx.showReceive();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user