mirror of
https://github.com/mempool/mempool.git
synced 2024-12-27 08:44:26 +01:00
Display "stack of X blocks" instead of "8th block" on the mempool block stack.
This commit is contained in:
parent
942e1a7d68
commit
a4c49d42af
@ -1,7 +1,7 @@
|
||||
<div class="container-xl" *ngIf="mempoolBlock$ | async as mempoolBlock">
|
||||
|
||||
<div class="title-block">
|
||||
<h1 class="float-left">{{ getGetOrdinal() }}</h1>
|
||||
<h1 class="float-left">{{ ordinal }}</h1>
|
||||
<button [routerLink]="['/' | relativeUrl]" class="btn btn-sm float-right mr-2 mt-2">✕</button>
|
||||
</div>
|
||||
|
||||
|
@ -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<MempoolBlock>;
|
||||
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';
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user