Adding countdown timer

refs #50
This commit is contained in:
softsimon 2020-04-10 01:05:21 +07:00
parent 38d424f793
commit fc7a5c2e28
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
2 changed files with 14 additions and 0 deletions

View File

@ -1,3 +1,8 @@
<div class="text-center pb-1" *ngIf="network === '' && latestBlockHeight && latestBlockHeight < 630000">
<h3>Quantitative Hardening in {{ 630000 - latestBlockHeight }} blocks (~<app-timespan [time]="(630000 - latestBlockHeight) * 10 * 60"></app-timespan>)</h3>
</div>
<div class="container-xl">
<hr>

View File

@ -4,6 +4,7 @@ import { StateService } from '../../services/state.service';
import { Block } from '../../interfaces/electrs.interface';
import { Subscription } from 'rxjs';
import { SeoService } from 'src/app/services/seo.service';
import { environment } from 'src/environments/environment';
@Component({
selector: 'app-latest-blocks',
@ -11,11 +12,15 @@ import { SeoService } from 'src/app/services/seo.service';
styleUrls: ['./latest-blocks.component.scss'],
})
export class LatestBlocksComponent implements OnInit, OnDestroy {
network = environment.network;
blocks: any[] = [];
blockSubscription: Subscription;
isLoading = true;
interval: any;
latestBlockHeight: number;
heightOfPageUntilBlocks = 430;
heightOfBlocksTableChunk = 470;
@ -34,6 +39,8 @@ export class LatestBlocksComponent implements OnInit, OnDestroy {
return;
}
this.latestBlockHeight = block.height;
if (block.height === this.blocks[0].height) {
return;
}
@ -66,6 +73,8 @@ export class LatestBlocksComponent implements OnInit, OnDestroy {
this.blocks = blocks;
this.isLoading = false;
this.latestBlockHeight = blocks[0].height;
const spaceForBlocks = window.innerHeight - this.heightOfPageUntilBlocks;
const chunks = Math.ceil(spaceForBlocks / this.heightOfBlocksTableChunk) - 1;
if (chunks > 0) {