Don't render full input witness if user does not press "show all"

This commit is contained in:
natsoni
2024-06-06 17:53:20 +02:00
parent f840ac951b
commit 77d42bfdbb
3 changed files with 39 additions and 50 deletions

View File

@@ -49,6 +49,7 @@ export class TransactionsListComponent implements OnInit, OnChanges {
inputRowLimit: number = 12;
outputRowLimit: number = 12;
showFullScript: { [vinIndex: number]: boolean } = {};
showFullWitness: { [vinIndex: number]: { [witnessIndex: number]: boolean } } = {};
constructor(
public stateService: StateService,
@@ -302,8 +303,16 @@ export class TransactionsListComponent implements OnInit, OnChanges {
if (this.showDetails$.value === true) {
this.showDetails$.next(false);
this.showFullScript = {};
this.showFullWitness = {};
} else {
this.showFullScript = this.transactions[0] ? this.transactions[0].vin.reduce((acc, _, i) => ({...acc, [i]: false}), {}) : {};
this.showFullWitness = this.transactions[0] ? this.transactions[0].vin.reduce((acc, vin, vinIndex) => {
acc[vinIndex] = vin.witness ? vin.witness.reduce((witnessAcc, _, witnessIndex) => {
witnessAcc[witnessIndex] = false;
return witnessAcc;
}, {}) : {};
return acc;
}, {}) : {};
this.showDetails$.next(true);
}
}
@@ -359,6 +368,10 @@ export class TransactionsListComponent implements OnInit, OnChanges {
this.showFullScript[vinIndex] = !this.showFullScript[vinIndex];
}
toggleShowFullWitness(vinIndex: number, witnessIndex: number): void {
this.showFullWitness[vinIndex][witnessIndex] = !this.showFullWitness[vinIndex][witnessIndex];
}
ngOnDestroy(): void {
this.outspendsSubscription.unsubscribe();
this.currencyChangeSubscription?.unsubscribe();