From 73f241e9c3384cdc1c9d01233bd3673cc3faa140 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Wed, 10 Apr 2024 13:53:21 +0900 Subject: [PATCH 1/2] Revert "Disable accelerate button after submission" This reverts commit e55b1740db5d5d2ba9a15d201400abdad08787e7. --- .../accelerate-preview/accelerate-preview.component.html | 4 ++-- .../accelerate-preview/accelerate-preview.component.ts | 7 ------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html index de834868d..b3bd8a868 100644 --- a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html +++ b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html @@ -26,7 +26,7 @@ -
+
You are currently on the waitlist
@@ -286,7 +286,7 @@
- @if (!hideCashApp && !(error || processing || showSuccess) && paymentType === 'cashapp') { + @if (!hideCashApp && paymentType === 'cashapp') {
Accelerate for with
diff --git a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts index e35f469eb..19edf9b7e 100644 --- a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts +++ b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts @@ -48,7 +48,6 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges math = Math; error = ''; - processing = false; showSuccess = false; estimateSubscription: Subscription; accelerationSubscription: Subscription; @@ -246,21 +245,18 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges if (this.accelerationSubscription) { this.accelerationSubscription.unsubscribe(); } - this.processing = true; this.accelerationSubscription = this.servicesApiService.accelerate$( this.tx.txid, this.userBid, this.accelerationUUID ).subscribe({ next: () => { - this.processing = false; this.audioService.playSound('ascend-chime-cartoon'); this.showSuccess = true; this.scrollToPreviewWithTimeout('successAlert', 'center'); this.estimateSubscription.unsubscribe(); }, error: (response) => { - this.processing = false; if (response.status === 403 && response.error === 'not_available') { this.error = 'waitlisted'; } else { @@ -363,14 +359,12 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges that.accelerationUUID ).subscribe({ next: () => { - this.processing = false; that.audioService.playSound('ascend-chime-cartoon'); that.showSuccess = true; that.scrollToPreviewWithTimeout('successAlert', 'center'); that.estimateSubscription.unsubscribe(); }, error: (response) => { - this.processing = false; if (response.status === 403 && response.error === 'not_available') { that.error = 'waitlisted'; } else { @@ -407,7 +401,6 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges submitCashappPay(): void { if (this.cashappSubmit) { this.cashappSubmit?.begin(); - this.processing = true; } } From fb8808ea598484d2adac58323e6a0c7379992f4b Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Wed, 10 Apr 2024 14:33:33 +0900 Subject: [PATCH 2/2] [accelerator] fix redirect url, fix UX --- .../accelerate-preview.component.html | 5 +++++ .../accelerate-preview.component.ts | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html index b3bd8a868..891ffce4a 100644 --- a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html +++ b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html @@ -14,6 +14,7 @@
+@if (!processingPayment) {

+} +@else if (!showSuccess && !error) { +
Processing payment...
+} If your tx is accelerated to ~{{ i | number : '1.0-0' }} sat/vB \ No newline at end of file diff --git a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts index 19edf9b7e..ca4e61c06 100644 --- a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts +++ b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts @@ -77,6 +77,7 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges square: any; cashAppPay: any; hideCashApp = false; + processingPayment = false; constructor( public stateService: StateService, @@ -85,6 +86,12 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges private audioService: AudioService, private cd: ChangeDetectorRef ) { + const urlParams = new URLSearchParams(window.location.search); + if (urlParams.get('cash_request_id')) { + this.processingPayment = true; + this.scrollToPreviewWithTimeout('successAlert', 'center'); + } + if (this.stateService.ref === 'https://cash.app/') { this.paymentType = 'cashapp'; this.insertSquare(); @@ -322,6 +329,7 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges this.cashAppPay.destroy(); } + const redirectHostname = document.location.hostname === 'localhost' ? 'http://localhost:4200': 'https://mempool.space'; const maxCostUsd = this.maxCost / 100_000_000 * conversions.USD; const paymentRequest = this.payments.paymentRequest({ countryCode: 'US', @@ -330,12 +338,12 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges amount: maxCostUsd.toString(), label: 'Total', pending: true, - productUrl: `https://mempool.space/tx/${this.tx.txid}`, + productUrl: `${redirectHostname}/tx/${this.tx.txid}`, }, button: { shape: 'semiround', size: 'small', theme: 'light'} }); this.cashAppPay = await this.payments.cashAppPay(paymentRequest, { - redirectURL: `https://mempool.space/tx/${this.tx.txid}`, + redirectURL: `${redirectHostname}/tx/${this.tx.txid}?acceleration=false`, referenceId: `accelerator-${this.tx.txid.substring(0, 15)}-${Math.round(new Date().getTime() / 1000)}`, button: { shape: 'semiround', size: 'small', theme: 'light'} }); @@ -344,6 +352,8 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges const that = this; this.cashAppPay.addEventListener('ontokenization', function (event) { + that.processingPayment = true; + that.scrollToPreviewWithTimeout('successAlert', 'center'); const { tokenResult, error } = event.detail; if (error) { this.error = error; @@ -361,7 +371,6 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges next: () => { that.audioService.playSound('ascend-chime-cartoon'); that.showSuccess = true; - that.scrollToPreviewWithTimeout('successAlert', 'center'); that.estimateSubscription.unsubscribe(); }, error: (response) => {