Bugfix and inprovments for arrow navigation.
This commit is contained in:
parent
78e41fc3d3
commit
bd641271a9
@ -1,11 +1,10 @@
|
|||||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { ActivatedRoute, ParamMap } from '@angular/router';
|
import { ActivatedRoute, ParamMap } from '@angular/router';
|
||||||
import { ElectrsApiService } from '../../services/electrs-api.service';
|
import { ElectrsApiService } from '../../services/electrs-api.service';
|
||||||
import { switchMap, tap, debounceTime } from 'rxjs/operators';
|
import { switchMap, tap, debounceTime, catchError } from 'rxjs/operators';
|
||||||
import { Block, Transaction, Vout } from '../../interfaces/electrs.interface';
|
import { Block, Transaction, Vout } from '../../interfaces/electrs.interface';
|
||||||
import { of, Observable } from 'rxjs';
|
import { of, empty } from 'rxjs';
|
||||||
import { StateService } from '../../services/state.service';
|
import { StateService } from '../../services/state.service';
|
||||||
import { WebsocketService } from 'src/app/services/websocket.service';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-block',
|
selector: 'app-block',
|
||||||
@ -28,12 +27,9 @@ export class BlockComponent implements OnInit, OnDestroy {
|
|||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private electrsApiService: ElectrsApiService,
|
private electrsApiService: ElectrsApiService,
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
private websocketService: WebsocketService,
|
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.websocketService.want(['blocks', 'stats', 'mempool-blocks']);
|
|
||||||
|
|
||||||
this.route.paramMap
|
this.route.paramMap
|
||||||
.pipe(
|
.pipe(
|
||||||
switchMap((params: ParamMap) => {
|
switchMap((params: ParamMap) => {
|
||||||
@ -68,8 +64,14 @@ export class BlockComponent implements OnInit, OnDestroy {
|
|||||||
this.isLoadingTransactions = true;
|
this.isLoadingTransactions = true;
|
||||||
this.transactions = null;
|
this.transactions = null;
|
||||||
}),
|
}),
|
||||||
debounceTime(250),
|
debounceTime(300),
|
||||||
switchMap((block) => this.electrsApiService.getBlockTransactions$(block.id))
|
switchMap((block) => this.electrsApiService.getBlockTransactions$(block.id)
|
||||||
|
.pipe(
|
||||||
|
catchError((err) => {
|
||||||
|
console.log(err);
|
||||||
|
return of([]);
|
||||||
|
}))
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.subscribe((transactions: Transaction[]) => {
|
.subscribe((transactions: Transaction[]) => {
|
||||||
if (this.fees === undefined) {
|
if (this.fees === undefined) {
|
||||||
|
@ -3,7 +3,6 @@ import { StateService } from 'src/app/services/state.service';
|
|||||||
import { ActivatedRoute, ParamMap } from '@angular/router';
|
import { ActivatedRoute, ParamMap } from '@angular/router';
|
||||||
import { switchMap, map } from 'rxjs/operators';
|
import { switchMap, map } from 'rxjs/operators';
|
||||||
import { MempoolBlock } from 'src/app/interfaces/websocket.interface';
|
import { MempoolBlock } from 'src/app/interfaces/websocket.interface';
|
||||||
import { WebsocketService } from 'src/app/services/websocket.service';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-mempool-block',
|
selector: 'app-mempool-block',
|
||||||
@ -17,12 +16,9 @@ export class MempoolBlockComponent implements OnInit, OnDestroy {
|
|||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
private websocketService: WebsocketService,
|
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.websocketService.want(['blocks', 'stats', 'mempool-blocks']);
|
|
||||||
|
|
||||||
this.route.paramMap.pipe(
|
this.route.paramMap.pipe(
|
||||||
switchMap((params: ParamMap) => {
|
switchMap((params: ParamMap) => {
|
||||||
this.mempoolBlockIndex = parseInt(params.get('id'), 10) || 0;
|
this.mempoolBlockIndex = parseInt(params.get('id'), 10) || 0;
|
||||||
|
@ -3,6 +3,7 @@ import { Subscription } from 'rxjs';
|
|||||||
import { MempoolBlock } from 'src/app/interfaces/websocket.interface';
|
import { MempoolBlock } from 'src/app/interfaces/websocket.interface';
|
||||||
import { StateService } from 'src/app/services/state.service';
|
import { StateService } from 'src/app/services/state.service';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { take } from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-mempool-blocks',
|
selector: 'app-mempool-blocks',
|
||||||
@ -69,6 +70,7 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
|
|||||||
this.router.navigate(['/mempool-block/', this.markIndex - 1]);
|
this.router.navigate(['/mempool-block/', this.markIndex - 1]);
|
||||||
} else {
|
} else {
|
||||||
this.stateService.blocks$
|
this.stateService.blocks$
|
||||||
|
.pipe(take(8))
|
||||||
.subscribe((block) => {
|
.subscribe((block) => {
|
||||||
if (this.stateService.latestBlockHeight === block.height) {
|
if (this.stateService.latestBlockHeight === block.height) {
|
||||||
this.router.navigate(['/block/', block.id], { state: { data: { block } }});
|
this.router.navigate(['/block/', block.id], { state: { data: { block } }});
|
||||||
|
@ -38,8 +38,6 @@ export class TransactionComponent implements OnInit, OnDestroy {
|
|||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.websocketService.want(['blocks', 'stats', 'mempool-blocks']);
|
|
||||||
|
|
||||||
this.route.paramMap.pipe(
|
this.route.paramMap.pipe(
|
||||||
switchMap((params: ParamMap) => {
|
switchMap((params: ParamMap) => {
|
||||||
this.txId = params.get('id') || '';
|
this.txId = params.get('id') || '';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user