persist confirm-tx view across popup close/reopen (closes #77)
All checks were successful
check / check (push) Successful in 21s
All checks were successful
check / check (push) Successful in 21s
Add confirm-tx to RESTORABLE_VIEWS and save pendingTx in state.viewData so the confirmation screen survives the popup lifecycle. On restore, re-render the full confirmation view including gas estimate.
This commit is contained in:
@@ -74,6 +74,7 @@ const RESTORABLE_VIEWS = new Set([
|
|||||||
"receive",
|
"receive",
|
||||||
"settings",
|
"settings",
|
||||||
"settings-addtoken",
|
"settings-addtoken",
|
||||||
|
"confirm-tx",
|
||||||
"transaction",
|
"transaction",
|
||||||
"success-tx",
|
"success-tx",
|
||||||
"error-tx",
|
"error-tx",
|
||||||
@@ -127,6 +128,13 @@ function restoreView() {
|
|||||||
case "settings-addtoken":
|
case "settings-addtoken":
|
||||||
settingsAddToken.show();
|
settingsAddToken.show();
|
||||||
break;
|
break;
|
||||||
|
case "confirm-tx":
|
||||||
|
if (state.viewData && state.viewData.pendingTx) {
|
||||||
|
confirmTx.restore();
|
||||||
|
} else {
|
||||||
|
fallbackView();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "transaction":
|
case "transaction":
|
||||||
if (state.viewData && state.viewData.tx) {
|
if (state.viewData && state.viewData.tx) {
|
||||||
transactionDetail.render();
|
transactionDetail.render();
|
||||||
|
|||||||
@@ -38,6 +38,13 @@ const EXT_ICON =
|
|||||||
|
|
||||||
let pendingTx = null;
|
let pendingTx = null;
|
||||||
|
|
||||||
|
function restore() {
|
||||||
|
const d = state.viewData;
|
||||||
|
if (d && d.pendingTx) {
|
||||||
|
show(d.pendingTx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function etherscanTokenLink(address) {
|
function etherscanTokenLink(address) {
|
||||||
return `https://etherscan.io/token/${address}`;
|
return `https://etherscan.io/token/${address}`;
|
||||||
}
|
}
|
||||||
@@ -217,6 +224,7 @@ function show(txInfo) {
|
|||||||
// Gas estimate — show placeholder then fetch async
|
// Gas estimate — show placeholder then fetch async
|
||||||
$("confirm-fee").classList.remove("hidden");
|
$("confirm-fee").classList.remove("hidden");
|
||||||
$("confirm-fee-amount").textContent = "Estimating...";
|
$("confirm-fee-amount").textContent = "Estimating...";
|
||||||
|
state.viewData = { pendingTx: txInfo };
|
||||||
showView("confirm-tx");
|
showView("confirm-tx");
|
||||||
|
|
||||||
estimateGas(txInfo);
|
estimateGas(txInfo);
|
||||||
@@ -347,4 +355,4 @@ function init(ctx) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { init, show };
|
module.exports = { init, show, restore };
|
||||||
|
|||||||
Reference in New Issue
Block a user