taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 9875714a026484af1d20fea7aa8762432ce022b9
parent 394f70b9109f035144867bb003a953fec5924d2d
Author: Sebastian <sebasjm@gmail.com>
Date:   Wed, 17 Jan 2024 16:19:10 -0300

do not add a new request if there is one already

Diffstat:
Mpackages/taler-wallet-core/src/operations/withdraw.ts | 23+++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -1905,6 +1905,11 @@ export interface GetWithdrawalDetailsForUriOpts { notifyChangeFromPendingTimeoutMs?: number; } +type WithdrawalOperationMemoryMap = { + [uri: string]: boolean | undefined; +} +const ongoingChecks: WithdrawalOperationMemoryMap = { +} /** * Get more information about a taler://withdraw URI. * @@ -1945,7 +1950,10 @@ export async function getWithdrawalDetailsForUri( ); }); - if (info.status === "pending" && opts.notifyChangeFromPendingTimeoutMs !== undefined) { + // FIXME: this should be removed after the extended version of + // withdrawal state machine. issue #8099 + if (info.status === "pending" && opts.notifyChangeFromPendingTimeoutMs !== undefined && !ongoingChecks[talerWithdrawUri]) { + ongoingChecks[talerWithdrawUri] = true; const bankApi = new TalerBankIntegrationHttpClient(info.apiBaseUrl, ws.http); console.log( `waiting operation (${info.operationId}) to change from pending`, @@ -1957,21 +1965,12 @@ export async function getWithdrawalDetailsForUri( console.log( `operation (${info.operationId}) to change to ${JSON.stringify(resp, undefined, 2)}`, ); - if (resp.type === "fail") { - //not found, this is rare since the previous request succeed - ws.notify({ - type: NotificationType.WithdrawalOperationTransition, - operationId: info.operationId, - state: info.status, - }) - return; - } - ws.notify({ type: NotificationType.WithdrawalOperationTransition, operationId: info.operationId, - state: resp.body.status, + state: resp.type === "fail" ? info.status : resp.body.status, }); + ongoingChecks[talerWithdrawUri] = false }) }