diff options
author | Florian Dold <florian@dold.me> | 2023-06-28 10:49:31 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-06-28 10:49:41 +0200 |
commit | 35ae9f2c22adcabd28747a1f2c4f21f51c732f42 (patch) | |
tree | 00f906371bb64ab6479d2fb203bf188e5da46b49 /packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts | |
parent | 97a9e92d8b104a94c376ae4fad8c5c811f5ef7e1 (diff) |
wallet-core: emit balance-change notifications, do less implicit background work
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts b/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts index 58a1c2b3c..3e5750af7 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts @@ -22,6 +22,7 @@ import { ExchangePurseMergeRequest, HttpStatusCode, Logger, + NotificationType, PeerContractTerms, PreparePeerPushCreditRequest, PreparePeerPushCreditResponse, @@ -60,7 +61,12 @@ import { } from "../index.js"; import { assertUnreachable } from "../util/assertUnreachable.js"; import { checkDbInvariant } from "../util/invariants.js"; -import { OperationAttemptResult, OperationAttemptResultType, constructTaskIdentifier, runLongpollAsync } from "./common.js"; +import { + OperationAttemptResult, + OperationAttemptResultType, + constructTaskIdentifier, + runLongpollAsync, +} from "./common.js"; import { updateExchangeFromUrl } from "./exchanges.js"; import { codecForExchangePurseStatus, @@ -206,6 +212,8 @@ export async function preparePeerPushCredit( }); }); + ws.notify({ type: NotificationType.BalanceChange }); + return { amount: purseStatus.balance, amountEffective: wi.withdrawalAmountEffective, @@ -631,15 +639,15 @@ export async function confirmPeerPushCredit( } peerPushPaymentIncomingId = parsedTx.peerPushPaymentIncomingId; } else { - throw Error("no transaction ID (or deprecated peerPushPaymentIncomingId) provided"); + throw Error( + "no transaction ID (or deprecated peerPushPaymentIncomingId) provided", + ); } await ws.db .mktx((x) => [x.contractTerms, x.peerPushPaymentIncoming]) .runReadWrite(async (tx) => { - peerInc = await tx.peerPushPaymentIncoming.get( - peerPushPaymentIncomingId, - ); + peerInc = await tx.peerPushPaymentIncoming.get(peerPushPaymentIncomingId); if (!peerInc) { return; } |