fix: a popup that opened on Welcome keeps refreshing once the first wallet is added (closes #530)
The ten-second refresh was started only by init(), and only when a wallet existed as the popup opened, so a popup that opened on Welcome refreshed the new wallet once and then showed that balance until it was reopened. init() and the three import paths on AddWallet now call startRefresh(), which refreshes at once and starts the ten-second refresh unless it is already running, and does nothing while the recovery screen is up. The two AddWallet tests that build their own context pass it in place of the refresh they passed before. Model: opus-5-5
This commit was merged in pull request #573.
This commit is contained in:
+17
-4
@@ -64,8 +64,8 @@ window.addEventListener("pagehide", () => pageClosed.abort());
|
||||
|
||||
let refreshInFlight = false;
|
||||
|
||||
// The ten-second refresh init() starts, stopped when the popup moves to the
|
||||
// recovery screen: there is no profile left to refresh.
|
||||
// The ten-second refresh startRefresh() starts, stopped when the popup moves to
|
||||
// the recovery screen: there is no profile left to refresh.
|
||||
let refreshTimer = null;
|
||||
|
||||
async function doRefreshAndRender() {
|
||||
@@ -99,9 +99,23 @@ async function doRefreshAndRender() {
|
||||
}
|
||||
}
|
||||
|
||||
// Refreshes now and every ten seconds from then on. Called once a wallet
|
||||
// exists: by init() when the popup opens with one, and by AddWallet when it
|
||||
// adds one, which in a popup that opened on Welcome is the first
|
||||
// (https://git.eeqj.de/sneak/AutistMask/issues/530). With the refresh already
|
||||
// running it starts no second one, and on the recovery screen it does nothing.
|
||||
function startRefresh() {
|
||||
if (!$("view-state-recovery").classList.contains("hidden")) return;
|
||||
doRefreshAndRender();
|
||||
if (refreshTimer === null) {
|
||||
refreshTimer = setInterval(doRefreshAndRender, 10000);
|
||||
}
|
||||
}
|
||||
|
||||
const ctx = {
|
||||
renderWalletList,
|
||||
doRefreshAndRender,
|
||||
startRefresh,
|
||||
pageClosed: pageClosed.signal,
|
||||
showAddWalletView: () => {
|
||||
pushCurrentView();
|
||||
@@ -318,8 +332,7 @@ async function init() {
|
||||
} else {
|
||||
renderWalletList();
|
||||
restoreView();
|
||||
doRefreshAndRender();
|
||||
refreshTimer = setInterval(doRefreshAndRender, 10000);
|
||||
startRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ async function importMnemonic(ctx) {
|
||||
showFlash("Ready.", 1000);
|
||||
}
|
||||
|
||||
ctx.doRefreshAndRender();
|
||||
ctx.startRefresh();
|
||||
}
|
||||
|
||||
async function importPrivateKey(ctx) {
|
||||
@@ -274,7 +274,7 @@ async function importPrivateKey(ctx) {
|
||||
ctx.renderWalletList();
|
||||
showView("main");
|
||||
|
||||
ctx.doRefreshAndRender();
|
||||
ctx.startRefresh();
|
||||
}
|
||||
|
||||
async function importXprvKey(ctx) {
|
||||
@@ -368,7 +368,7 @@ async function importXprvKey(ctx) {
|
||||
showFlash("Ready.", 1000);
|
||||
}
|
||||
|
||||
ctx.doRefreshAndRender();
|
||||
ctx.startRefresh();
|
||||
}
|
||||
|
||||
function init(ctx) {
|
||||
|
||||
Reference in New Issue
Block a user