Block navigation routing fix
This commit is contained in:
parent
7ce1cc5103
commit
4f21fc0d87
@ -8,10 +8,12 @@ import { Observable, of, Subscription } from 'rxjs';
|
|||||||
import { StateService } from '../../services/state.service';
|
import { StateService } from '../../services/state.service';
|
||||||
import { SeoService } from 'src/app/services/seo.service';
|
import { SeoService } from 'src/app/services/seo.service';
|
||||||
import { WebsocketService } from 'src/app/services/websocket.service';
|
import { WebsocketService } from 'src/app/services/websocket.service';
|
||||||
|
import { RelativeUrlPipe } from 'src/app/shared/pipes/relative-url/relative-url.pipe';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-block',
|
selector: 'app-block',
|
||||||
templateUrl: './block.component.html',
|
templateUrl: './block.component.html',
|
||||||
|
providers: [RelativeUrlPipe],
|
||||||
styleUrls: ['./block.component.scss']
|
styleUrls: ['./block.component.scss']
|
||||||
})
|
})
|
||||||
export class BlockComponent implements OnInit, OnDestroy {
|
export class BlockComponent implements OnInit, OnDestroy {
|
||||||
@ -51,6 +53,7 @@ export class BlockComponent implements OnInit, OnDestroy {
|
|||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
private seoService: SeoService,
|
private seoService: SeoService,
|
||||||
private websocketService: WebsocketService,
|
private websocketService: WebsocketService,
|
||||||
|
private relativeUrlPipe: RelativeUrlPipe,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -194,7 +197,7 @@ export class BlockComponent implements OnInit, OnDestroy {
|
|||||||
if (this.showNextBlocklink) {
|
if (this.showNextBlocklink) {
|
||||||
this.navigateToNextBlock();
|
this.navigateToNextBlock();
|
||||||
} else {
|
} else {
|
||||||
this.router.navigate([(this.network && this.stateService.env.BASE_MODULE === 'mempool' ? '/' + this.network : '') + '/mempool-block/', '0']);
|
this.router.navigate([this.relativeUrlPipe.transform('/mempool-block'), '0']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -277,13 +280,13 @@ export class BlockComponent implements OnInit, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const block = this.latestBlocks.find((b) => b.height === this.nextBlockHeight - 2);
|
const block = this.latestBlocks.find((b) => b.height === this.nextBlockHeight - 2);
|
||||||
this.router.navigate([(this.network && this.stateService.env.BASE_MODULE === 'mempool' ? '/' + this.network : '') + '/block/',
|
this.router.navigate([this.relativeUrlPipe.transform('/block/'),
|
||||||
block ? block.id : this.block.previousblockhash], { state: { data: { block, blockHeight: this.nextBlockHeight - 2 } } });
|
block ? block.id : this.block.previousblockhash], { state: { data: { block, blockHeight: this.nextBlockHeight - 2 } } });
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateToNextBlock() {
|
navigateToNextBlock() {
|
||||||
const block = this.latestBlocks.find((b) => b.height === this.nextBlockHeight);
|
const block = this.latestBlocks.find((b) => b.height === this.nextBlockHeight);
|
||||||
this.router.navigate([(this.network && this.stateService.env.BASE_MODULE === 'mempool' ? '/' + this.network : '') + '/block/',
|
this.router.navigate([this.relativeUrlPipe.transform('/block/'),
|
||||||
block ? block.id : this.nextBlockHeight], { state: { data: { block, blockHeight: this.nextBlockHeight } } });
|
block ? block.id : this.nextBlockHeight], { state: { data: { block, blockHeight: this.nextBlockHeight } } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,11 +6,13 @@ import { Router } from '@angular/router';
|
|||||||
import { take, map, switchMap } from 'rxjs/operators';
|
import { take, map, switchMap } from 'rxjs/operators';
|
||||||
import { feeLevels, mempoolFeeColors } from 'src/app/app.constants';
|
import { feeLevels, mempoolFeeColors } from 'src/app/app.constants';
|
||||||
import { specialBlocks } from 'src/app/app.constants';
|
import { specialBlocks } from 'src/app/app.constants';
|
||||||
|
import { RelativeUrlPipe } from 'src/app/shared/pipes/relative-url/relative-url.pipe';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-mempool-blocks',
|
selector: 'app-mempool-blocks',
|
||||||
templateUrl: './mempool-blocks.component.html',
|
templateUrl: './mempool-blocks.component.html',
|
||||||
styleUrls: ['./mempool-blocks.component.scss'],
|
styleUrls: ['./mempool-blocks.component.scss'],
|
||||||
|
providers: [RelativeUrlPipe],
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class MempoolBlocksComponent implements OnInit, OnDestroy {
|
export class MempoolBlocksComponent implements OnInit, OnDestroy {
|
||||||
@ -52,6 +54,7 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
public stateService: StateService,
|
public stateService: StateService,
|
||||||
private cd: ChangeDetectorRef,
|
private cd: ChangeDetectorRef,
|
||||||
|
private relativeUrlPipe: RelativeUrlPipe,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -166,19 +169,19 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
if (event.key === 'ArrowRight') {
|
if (event.key === 'ArrowRight') {
|
||||||
if (this.mempoolBlocks[this.markIndex - 1]) {
|
if (this.mempoolBlocks[this.markIndex - 1]) {
|
||||||
this.router.navigate([(this.network ? '/' + this.network : '') + '/mempool-block/', this.markIndex - 1]);
|
this.router.navigate([this.relativeUrlPipe.transform('mempool-block/'), this.markIndex - 1]);
|
||||||
} else {
|
} else {
|
||||||
this.stateService.blocks$
|
this.stateService.blocks$
|
||||||
.pipe(take(this.stateService.env.MEMPOOL_BLOCKS_AMOUNT))
|
.pipe(take(this.stateService.env.MEMPOOL_BLOCKS_AMOUNT))
|
||||||
.subscribe(([block]) => {
|
.subscribe(([block]) => {
|
||||||
if (this.stateService.latestBlockHeight === block.height) {
|
if (this.stateService.latestBlockHeight === block.height) {
|
||||||
this.router.navigate([(this.network ? '/' + this.network : '') + '/block/', block.id], { state: { data: { block } }});
|
this.router.navigate([this.relativeUrlPipe.transform('/block/'), block.id], { state: { data: { block } }});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (event.key === 'ArrowLeft') {
|
} else if (event.key === 'ArrowLeft') {
|
||||||
if (this.mempoolBlocks[this.markIndex + 1]) {
|
if (this.mempoolBlocks[this.markIndex + 1]) {
|
||||||
this.router.navigate([(this.network ? '/' + this.network : '') + '/mempool-block/', this.markIndex + 1]);
|
this.router.navigate([this.relativeUrlPipe.transform('/mempool-block/'), this.markIndex + 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user