fix: a popup that opened on Welcome keeps refreshing once the first wallet is added (closes #530)
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run

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:
2026-10-19 03:19:53 +02:00
parent b923b2c19c
commit d2fd0f532a
5 changed files with 161 additions and 9 deletions
+17 -4
View File
@@ -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();
}
}