From 6cd1f9e8703d78d9ada0b6d2905d4eae02b2d0d4 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Tue, 22 Nov 2022 14:48:34 +0900 Subject: [PATCH] Fix load more inputs for non-esplora backends --- .../transactions-list.component.html | 2 +- .../transactions-list.component.ts | 30 ++++++++++++------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/frontend/src/app/components/transactions-list/transactions-list.component.html b/frontend/src/app/components/transactions-list/transactions-list.component.html index cd2d58f2f..139da368b 100644 --- a/frontend/src/app/components/transactions-list/transactions-list.component.html +++ b/frontend/src/app/components/transactions-list/transactions-list.component.html @@ -283,7 +283,7 @@
{{ tx.fee / (tx.weight / 4) | feeRounding }} sat/vB  – {{ tx.fee | number }} sat
-
Show all inputs to reveal fee data
+
Show more inputs to reveal fee data
diff --git a/frontend/src/app/components/transactions-list/transactions-list.component.ts b/frontend/src/app/components/transactions-list/transactions-list.component.ts index 0d9d60c95..be5bd5343 100644 --- a/frontend/src/app/components/transactions-list/transactions-list.component.ts +++ b/frontend/src/app/components/transactions-list/transactions-list.component.ts @@ -209,17 +209,19 @@ export class TransactionsListComponent implements OnInit, OnChanges { } loadMoreInputs(tx: Transaction): void { - tx['@vinLimit'] = false; - - this.electrsApiService.getTransaction$(tx.txid) - .subscribe((newTx) => { - tx.vin = newTx.vin; - tx.fee = newTx.fee; - this.ref.markForCheck(); - }); + if (!tx['@vinLoaded']) { + this.electrsApiService.getTransaction$(tx.txid) + .subscribe((newTx) => { + tx['@vinLoaded'] = true; + tx.vin = newTx.vin; + tx.fee = newTx.fee; + this.ref.markForCheck(); + }); + } } showMoreInputs(tx: Transaction): void { + this.loadMoreInputs(tx); tx['@vinLimit'] = this.getVinLimit(tx, true); } @@ -228,11 +230,19 @@ export class TransactionsListComponent implements OnInit, OnChanges { } getVinLimit(tx: Transaction, next = false): number { - return Math.min(Math.max(tx['@vinLimit'] || 0, this.inputRowLimit) + (next ? this.showMoreIncrement : 0), tx.vin.length); + if ((tx['@vinLimit'] || 0) > this.inputRowLimit) { + return Math.min(tx['@vinLimit'] + (next ? this.showMoreIncrement : 0), tx.vin.length); + } else { + return Math.min((next ? this.showMoreIncrement : this.inputRowLimit), tx.vin.length); + } } getVoutLimit(tx: Transaction, next = false): number { - return Math.min(Math.max(tx['@voutLimit'] || 0, this.outputRowLimit) + (next ? this.showMoreIncrement : 0), tx.vout.length); + if ((tx['@voutLimit'] || 0) > this.outputRowLimit) { + return Math.min(tx['@voutLimit'] + (next ? this.showMoreIncrement : 0), tx.vout.length); + } else { + return Math.min((next ? this.showMoreIncrement : this.outputRowLimit), tx.vout.length); + } } ngOnDestroy(): void {