diff --git a/frontend/src/app/components/mempool-block/mempool-block.component.html b/frontend/src/app/components/mempool-block/mempool-block.component.html index fb324f5e7..91406c593 100644 --- a/frontend/src/app/components/mempool-block/mempool-block.component.html +++ b/frontend/src/app/components/mempool-block/mempool-block.component.html @@ -1,7 +1,7 @@
-

{{ getGetOrdinal() }}

+

{{ ordinal }}

diff --git a/frontend/src/app/components/mempool-block/mempool-block.component.ts b/frontend/src/app/components/mempool-block/mempool-block.component.ts index 897e091b3..1e78145ff 100644 --- a/frontend/src/app/components/mempool-block/mempool-block.component.ts +++ b/frontend/src/app/components/mempool-block/mempool-block.component.ts @@ -5,6 +5,7 @@ import { switchMap, map, tap, filter } from 'rxjs/operators'; import { MempoolBlock } from 'src/app/interfaces/websocket.interface'; import { Observable } from 'rxjs'; import { SeoService } from 'src/app/services/seo.service'; +import { env } from 'src/app/app.constants'; @Component({ selector: 'app-mempool-block', @@ -15,6 +16,7 @@ export class MempoolBlockComponent implements OnInit, OnDestroy { network = ''; mempoolBlockIndex: number; mempoolBlock$: Observable; + ordinal: string; constructor( private route: ActivatedRoute, @@ -34,7 +36,8 @@ export class MempoolBlockComponent implements OnInit, OnDestroy { while (!mempoolBlocks[this.mempoolBlockIndex]) { this.mempoolBlockIndex--; } - this.seoService.setTitle(this.getGetOrdinal()); + this.setOrdinal(mempoolBlocks[this.mempoolBlockIndex]); + this.seoService.setTitle(this.ordinal); return mempoolBlocks[this.mempoolBlockIndex]; }) ); @@ -52,14 +55,16 @@ export class MempoolBlockComponent implements OnInit, OnDestroy { this.stateService.markBlock$.next({}); } - getGetOrdinal() { + setOrdinal(mempoolBlock: MempoolBlock) { + const blocksInBlock = Math.ceil(mempoolBlock.blockVSize / 1000000); if (this.mempoolBlockIndex === 0) { - return 'Next block'; + this.ordinal = 'Next block'; + } else if (this.mempoolBlockIndex === env.KEEP_BLOCKS_AMOUNT - 1 && blocksInBlock > 1 ) { + this.ordinal = `Stack of ${blocksInBlock} blocks`; + } else { + const s = ['th', 'st', 'nd', 'rd']; + const v = this.mempoolBlockIndex + 1 % 100; + this.ordinal = this.mempoolBlockIndex + 1 + (s[(v - 20) % 10] || s[v] || s[0]) + ' next block'; } - - const s = ['th', 'st', 'nd', 'rd']; - const v = this.mempoolBlockIndex + 1 % 100; - return this.mempoolBlockIndex + 1 + (s[(v - 20) % 10] || s[v] || s[0]) + ' next block'; } - }