fix btc payment waiting reply

This commit is contained in:
softsimon 2024-07-22 20:13:13 +08:00
parent 8116b50d50
commit 1f357408ac
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7

View File

@ -3,7 +3,7 @@ import { FormBuilder, FormGroup } from '@angular/forms';
import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Subscription, of, timer } from 'rxjs'; import { Subscription, of, timer } from 'rxjs';
import { retry, switchMap, tap } from 'rxjs/operators'; import { filter, repeat, retry, switchMap, take, tap } from 'rxjs/operators';
import { ServicesApiServices } from '../../services/services-api.service'; import { ServicesApiServices } from '../../services/services-api.service';
@Component({ @Component({
@ -73,11 +73,11 @@ export class BitcoinInvoiceComponent implements OnInit, OnChanges, OnDestroy {
this.paymentStatus = 4; this.paymentStatus = 4;
} }
this.paymentStatusSubscription = this.apiService.getPaymentStatus$(this.invoice.btcpayInvoiceId).pipe( this.paymentStatusSubscription = this.apiService.getPaymentStatus$(this.invoice.btcpayInvoiceId).pipe(
retry({ delay: () => timer(2000)}) retry({ delay: () => timer(2000)}),
).subscribe((response) => { repeat({delay: 2000}),
if (response.status === 204 || response.status === 404) { filter((response) => response.status !== 204 && response.status !== 404),
return; take(1),
} ).subscribe(() => {
this.paymentStatus = 3; this.paymentStatus = 3;
this.completed.emit(); this.completed.emit();
}); });