Fix for empty mempool block position

fixes #938
This commit is contained in:
softsimon 2021-11-17 12:37:40 +04:00
parent d25edea0f3
commit 1b5418413c

View File

@ -79,6 +79,14 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
switchMap(() => combineLatest([
this.stateService.blocks$.pipe(map(([block]) => block)),
this.stateService.mempoolBlocks$
.pipe(
map((mempoolBlocks) => {
if (!mempoolBlocks.length) {
return [{ index: 0, blockSize: 0, blockVSize: 0, feeRange: [0, 0], medianFee: 0, nTx: 0, totalFees: 0 }];
}
return mempoolBlocks;
}),
)
])),
map(([lastBlock, mempoolBlocks]) => {
mempoolBlocks.forEach((block, i) => {
@ -89,14 +97,10 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
}
});
if (!mempoolBlocks.length) {
const emptyBlock = [{ index: 0, blockSize: 0, blockVSize: 0, feeRange: [0, 0], medianFee: 0, nTx: 0, totalFees: 0 }];
this.mempoolBlocks = emptyBlock;
} else {
const stringifiedBlocks = JSON.stringify(mempoolBlocks);
this.mempoolBlocksFull = JSON.parse(stringifiedBlocks);
this.mempoolBlocks = this.reduceMempoolBlocksToFitScreen(JSON.parse(stringifiedBlocks));
}
this.updateMempoolBlockStyles();
this.calculateTransactionPosition();
return this.mempoolBlocks;