Arrow navigation fix.

Liquid native asset notification fix.
This commit is contained in:
softsimon
2020-05-10 01:34:28 +07:00
parent c08a4c8424
commit 1d542c15e4
4 changed files with 47 additions and 21 deletions

View File

@@ -10,6 +10,7 @@ import { Router } from '@angular/router';
styleUrls: ['./blockchain-blocks.component.scss']
})
export class BlockchainBlocksComponent implements OnInit, OnDestroy {
network = '';
blocks: Block[] = [];
markHeight: number;
blocksSubscription: Subscription;
@@ -26,6 +27,8 @@ export class BlockchainBlocksComponent implements OnInit, OnDestroy {
) { }
ngOnInit() {
this.stateService.networkChanged$.subscribe((network) => this.network = network);
this.blocksSubscription = this.stateService.blocks$
.subscribe((block) => {
if (this.blocks.some((b) => b.height === block.height)) {
@@ -60,14 +63,16 @@ export class BlockchainBlocksComponent implements OnInit, OnDestroy {
if (event.key === 'ArrowRight') {
const blockindex = this.blocks.findIndex((b) => b.height === this.markHeight);
if (this.blocks[blockindex + 1]) {
this.router.navigate(['/block/', this.blocks[blockindex + 1].id], { state: { data: { block: this.blocks[blockindex + 1] } } });
this.router.navigate([(this.network ? '/' + this.network : '') + '/block/',
this.blocks[blockindex + 1].id], { state: { data: { block: this.blocks[blockindex + 1] } } });
}
} else if (event.key === 'ArrowLeft') {
const blockindex = this.blocks.findIndex((b) => b.height === this.markHeight);
if (blockindex === 0) {
this.router.navigate(['/mempool-block/', '0']);
this.router.navigate([(this.network ? '/' + this.network : '') + '/mempool-block/', '0']);
} else {
this.router.navigate(['/block/', this.blocks[blockindex - 1].id], { state: { data: { block: this.blocks[blockindex - 1] }}});
this.router.navigate([(this.network ? '/' + this.network : '') + '/block/',
this.blocks[blockindex - 1].id], { state: { data: { block: this.blocks[blockindex - 1] }}});
}
}
}