diff options
author | Sebastian <sebasjm@gmail.com> | 2024-01-17 16:19:10 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-01-17 16:19:10 -0300 |
commit | 9875714a026484af1d20fea7aa8762432ce022b9 (patch) | |
tree | e3ec1e500b91c9818d3eec000b31844a40be7b2c /packages/taler-wallet-core | |
parent | 394f70b9109f035144867bb003a953fec5924d2d (diff) | |
download | wallet-core-9875714a026484af1d20fea7aa8762432ce022b9.tar.xz |
do not add a new request if there is one already
Diffstat (limited to 'packages/taler-wallet-core')
-rw-r--r-- | packages/taler-wallet-core/src/operations/withdraw.ts | 23 |
1 files 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 index 6c7e8c37a..29c2cae40 100644 --- 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 }) } |