addding balance recheck back to login
This commit is contained in:
@@ -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 => ({
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user