aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-01 22:56:13 -0700
committerAdam Soltys <[email protected]>2026-08-01 22:56:13 -0700
commit88d93de66b9ba713c5cc1a8fc5b1528ea1d74fb8 (patch)
tree6b4021a5ce26f376e4a285005efcf9b6abb37a53 /src
parent232e2935a3c390ef78f670d978ff98e934693526 (diff)
downloadcoinosv3-88d93de66b9ba713c5cc1a8fc5b1528ea1d74fb8.tar.gz
coinosv3-88d93de66b9ba713c5cc1a8fc5b1528ea1d74fb8.zip
Stop the Ark card flickering on the settings page
Every synced snapshot re-ran initArk() while Ark was unconnected, and initArk() calls stopArk() first — so each arriving snapshot tore down and restarted the connection, flashing 'Connecting to the Ark server…' and jittering the page. Automatic re-inits are now skipped while a connection exists or is in flight, and rate-limited to one per 20s; user-driven reconnects (switching servers, the connect button) are unaffected. Co-Authored-By: Claude Fable 5 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/features/ark.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/features/ark.js b/src/features/ark.js
index 8229ead..0981918 100644
--- a/src/features/ark.js
+++ b/src/features/ark.js
@@ -235,7 +235,7 @@ export function arkFeature(ctx) {
// is what resolves it: the manager learns the server's pubkey and
// adopts the held state if it matches — a seed imported on a new
// device would otherwise show no ark balance until some manual poke.
- if (!mine) setTimeout(() => initArk(), 0);
+ if (!mine) setTimeout(() => maybeInitArk(), 0);
return;
}
const local = wallet.loadArkState(cfg.ark);
@@ -251,7 +251,7 @@ export function arkFeature(ctx) {
// The merge brought vtxos our live manager doesn't have — (re)connect so
// the balance actually shows.
const novel = mergedN > localN || (mergedN && (!ark || !ark.state));
- if (mergedN && novel) setTimeout(() => initArk(), 0);
+ if (mergedN && novel) setTimeout(() => maybeInitArk(), 0);
},
});
@@ -288,9 +288,22 @@ export function arkFeature(ctx) {
function initArk() {
stopArk();
ui.arkError = '';
+ lastAutoInit = Date.now();
if (arkAvailable() && arkWanted()) connectArk().catch(() => {});
}
+ // Automatic re-inits (a synced snapshot arriving) must not restart a
+ // connection that is already in flight, or retry in a tight loop when the
+ // server is unreachable: each one calls stopArk() first, so the settings
+ // card's "connecting" indicator flickers on every snapshot. User-driven
+ // calls to initArk() stay immediate.
+ let lastAutoInit = 0;
+ function maybeInitArk() {
+ if (ark || arkConnectPromise) return;
+ if (Date.now() - lastAutoInit < 20000) return;
+ initArk();
+ }
+
function connectArk() {
if (ark) return Promise.resolve(ark);
if (arkConnectPromise) return arkConnectPromise;