revert fully back to cached balance

This commit is contained in:
Blake Kaufman
2026-07-06 08:21:03 -04:00
parent 6980140192
commit 76823c36c5
+6 -2
View File
@@ -75,9 +75,11 @@ export async function initializeSparkSession({
// painted by the loading screen for instant first-paint, but returning
// users must still get an authoritative read so a stale snapshot can never
// persist until a manual pull-to-refresh.
let balanceSnapshot = false;
let skipBalanceFetch = false;
let balanceSnapshot = {};
if (cachedIdentityPubKey) {
balanceSnapshot = await getAccountBalanceSnapshot(cachedIdentityPubKey);
skipBalanceFetch = balanceSnapshot !== null;
}
// Only fetch fresh txs when restoring — returning users keep prev.transactions
const needsFreshTxs = !hasRestoreCompleted;
@@ -87,7 +89,9 @@ export async function initializeSparkSession({
: null;
const [balance, sparkAddress, freshIdentityPubKey] = await Promise.all([
getBalanceWithTimeout(mnemonic, 10000),
skipBalanceFetch
? Promise.resolve({ didWork: false })
: getSparkBalance(mnemonic),
getSparkAddress(mnemonic),
cachedIdentityPubKey
? Promise.resolve(cachedIdentityPubKey)