From 5af31804c98c53691fd03dc0083f10d694cfeb75 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 29 Feb 2024 23:50:30 +0100 Subject: fix condition --- packages/taler-wallet-core/src/wallet.ts | 68 ++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 30 deletions(-) (limited to 'packages/taler-wallet-core/src/wallet.ts') diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index b397c43d5..879508036 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -172,7 +172,6 @@ import { CoinSourceType, ConfigRecordKey, DenominationRecord, - OperationRetryRecord, WalletDbReadOnlyTransaction, WalletStoresV1, clearDatabase, @@ -181,7 +180,6 @@ import { openStoredBackupsDatabase, openTalerDatabase, timestampAbsoluteFromDb, - timestampPreciseFromDb, timestampProtocolToDb, } from "./db.js"; import { @@ -519,9 +517,9 @@ async function dumpCoins(wex: WalletExecutionContext): Promise { ageCommitmentProof: c.ageCommitmentProof, spend_allocation: c.spendAllocation ? { - amount: c.spendAllocation.amount, - id: c.spendAllocation.id, - } + amount: c.spendAllocation.amount, + id: c.spendAllocation.id, + } : undefined, }); } @@ -989,31 +987,41 @@ async function dispatchRequestInternal( return {}; } case WalletApiOperation.GetActiveTasks: { - const allTasksId = wex.taskScheduler.getActiveTasks() + const allTasksId = wex.taskScheduler.getActiveTasks(); + + const tasksInfo = await Promise.all( + allTasksId.map(async (id) => { + return await wex.ws.db.runReadOnlyTx( + ["operationRetries"], + async (tx) => { + return tx.operationRetries.get(id); + }, + ); + }), + ); - const tasksInfo = await Promise.all(allTasksId.map(async (id) => { - return await wex.ws.db.runReadOnlyTx( - ["operationRetries"], - async (tx) => { - return tx.operationRetries.get(id); - }, - ) - })) - - const tasks = allTasksId - .map((taskId, i): ActiveTask => { - const transaction = convertTaskToTransactionId(taskId); - const d = tasksInfo[i] - - const firstTry = !d?undefined:timestampAbsoluteFromDb(d.retryInfo.firstTry) - const nextTry = !d?undefined:timestampAbsoluteFromDb(d.retryInfo.nextRetry) - const counter = d?.retryInfo.retryCounter - const lastError = d?.lastError - - return { - id: taskId, counter, firstTry, nextTry, lastError, transaction - } - }) + const tasks = allTasksId.map((taskId, i): ActiveTask => { + const transaction = convertTaskToTransactionId(taskId); + const d = tasksInfo[i]; + + const firstTry = !d + ? undefined + : timestampAbsoluteFromDb(d.retryInfo.firstTry); + const nextTry = !d + ? undefined + : timestampAbsoluteFromDb(d.retryInfo.nextRetry); + const counter = d?.retryInfo.retryCounter; + const lastError = d?.lastError; + + return { + id: taskId, + counter, + firstTry, + nextTry, + lastError, + transaction, + }; + }); return { tasks }; } case WalletApiOperation.FailTransaction: { @@ -1491,7 +1499,7 @@ async function handleCoreApiRequest( wex = getObservedWalletExecutionContext(ws, CancellationToken.CONTINUE, oc); } else { oc = { - observe(evt) { }, + observe(evt) {}, }; wex = getNormalWalletExecutionContext(ws, CancellationToken.CONTINUE, oc); } -- cgit v1.2.3