addding balance recheck back to login

This commit is contained in:
Blake Kaufman
2026-07-03 13:05:16 -04:00
parent 00b7235e58
commit 73b93e0d1d
2 changed files with 11 additions and 9 deletions
+8 -8
View File
@@ -72,12 +72,13 @@ export async function initializeSparkSession({
// Fire immediately — never blocks the critical path
cleanStalePendingSparkLightningTransactions();
// Skip getSparkBalance if a snapshot already exists for this account
// (loading screen applied it; the balanceUpdateHandler will update it)
let skipBalanceFetch = false;
// Always fetch a live balance on connect. The cached snapshot is already
// 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;
if (cachedIdentityPubKey) {
const snapshot = await getAccountBalanceSnapshot(cachedIdentityPubKey);
skipBalanceFetch = snapshot !== null;
balanceSnapshot = await getAccountBalanceSnapshot(cachedIdentityPubKey);
}
// Only fetch fresh txs when restoring — returning users keep prev.transactions
const needsFreshTxs = !hasRestoreCompleted;
@@ -87,9 +88,7 @@ export async function initializeSparkSession({
: null;
const [balance, sparkAddress, freshIdentityPubKey] = await Promise.all([
skipBalanceFetch
? Promise.resolve({ didWork: false })
: getBalanceWithTimeout(mnemonic),
getBalanceWithTimeout(mnemonic, 10000),
getSparkAddress(mnemonic),
cachedIdentityPubKey
? Promise.resolve(cachedIdentityPubKey)
@@ -114,6 +113,7 @@ export async function initializeSparkSession({
const storageObject = {
identityPubKey,
sparkAddress: sparkAddress.response,
...(balanceSnapshot ?? {}),
didConnect: true,
};
setSparkInformation(prev => ({
+3 -1
View File
@@ -953,7 +953,9 @@ async function processLightningTransaction(
if (details.direction === 'OUTGOING' && paymentStatus === 'failed')
return {
...txStateUpdate,
id: txStateUpdate.sparkID,
useTempId: true,
tempId: txStateUpdate.sparkID,
id: sparkResponse.transfer.sparkId,
details: {
...details,
},