From 7b3cc6372b67747056b7c53bb33bf5cf2b7cc2a2 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Tue, 23 Jul 2024 15:17:22 +0000 Subject: [PATCH] [accelerator] frontend on-demand polling support --- .../accelerate-checkout/accelerate-checkout.component.ts | 9 +++++++-- frontend/src/app/services/api.service.ts | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.ts b/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.ts index 2512191b9..185238f72 100644 --- a/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.ts +++ b/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.ts @@ -9,6 +9,7 @@ import { Transaction } from '../../interfaces/electrs.interface'; import { MiningStats } from '../../services/mining.service'; import { IAuth, AuthServiceMempool } from '../../services/auth.service'; import { EnterpriseService } from '../../services/enterprise.service'; +import { ApiService } from '../../services/api.service'; export type PaymentMethod = 'balance' | 'bitcoin' | 'cashapp'; @@ -123,6 +124,7 @@ export class AccelerateCheckout implements OnInit, OnDestroy { constructor( public stateService: StateService, + private apiService: ApiService, private servicesApiService: ServicesApiServices, private etaService: EtaService, private audioService: AudioService, @@ -370,10 +372,11 @@ export class AccelerateCheckout implements OnInit, OnDestroy { this.accelerationUUID ).subscribe({ next: () => { + this.apiService.logAccelerationRequest$(this.tx.txid).subscribe(); this.audioService.playSound('ascend-chime-cartoon'); this.showSuccess = true; this.estimateSubscription.unsubscribe(); - this.moveToStep('paid') + this.moveToStep('paid'); }, error: (response) => { this.accelerateError = response.error; @@ -481,6 +484,7 @@ export class AccelerateCheckout implements OnInit, OnDestroy { that.accelerationUUID ).subscribe({ next: () => { + this.apiService.logAccelerationRequest$(this.tx.txid).subscribe(); that.audioService.playSound('ascend-chime-cartoon'); if (that.cashAppPay) { that.cashAppPay.destroy(); @@ -530,9 +534,10 @@ export class AccelerateCheckout implements OnInit, OnDestroy { } bitcoinPaymentCompleted(): void { + this.apiService.logAccelerationRequest$(this.tx.txid).subscribe(); this.audioService.playSound('ascend-chime-cartoon'); this.estimateSubscription.unsubscribe(); - this.moveToStep('paid') + this.moveToStep('paid'); } isLoggedIn(): boolean { diff --git a/frontend/src/app/services/api.service.ts b/frontend/src/app/services/api.service.ts index d7efa4d02..fa52ec707 100644 --- a/frontend/src/app/services/api.service.ts +++ b/frontend/src/app/services/api.service.ts @@ -536,6 +536,10 @@ export class ApiService { ); } + logAccelerationRequest$(txid: string): Observable { + return this.httpClient.post(this.apiBaseUrl + this.apiBasePath + '/api/v1/acceleration/request/' + txid, ''); + } + // Cache methods async setBlockAuditLoaded(hash: string) { this.blockAuditLoaded[hash] = true;