Improved how mempool blocks handle updates
This commit is contained in:
parent
bd641271a9
commit
245af5fa8f
@ -1,4 +1,4 @@
|
|||||||
<div class="container-xl" *ngIf="mempoolBlock">
|
<div class="container-xl" *ngIf="mempoolBlock$ | async as mempoolBlock">
|
||||||
|
|
||||||
<div class="title-block">
|
<div class="title-block">
|
||||||
<h1>Mempool block</h1>
|
<h1>Mempool block</h1>
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { StateService } from 'src/app/services/state.service';
|
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, tap } from 'rxjs/operators';
|
||||||
import { MempoolBlock } from 'src/app/interfaces/websocket.interface';
|
import { MempoolBlock } from 'src/app/interfaces/websocket.interface';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-mempool-block',
|
selector: 'app-mempool-block',
|
||||||
@ -11,7 +12,7 @@ import { MempoolBlock } from 'src/app/interfaces/websocket.interface';
|
|||||||
})
|
})
|
||||||
export class MempoolBlockComponent implements OnInit, OnDestroy {
|
export class MempoolBlockComponent implements OnInit, OnDestroy {
|
||||||
mempoolBlockIndex: number;
|
mempoolBlockIndex: number;
|
||||||
mempoolBlock: MempoolBlock;
|
mempoolBlock$: Observable<MempoolBlock>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
@ -19,19 +20,24 @@ export class MempoolBlockComponent implements OnInit, OnDestroy {
|
|||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.route.paramMap.pipe(
|
this.mempoolBlock$ = this.route.paramMap
|
||||||
switchMap((params: ParamMap) => {
|
.pipe(
|
||||||
this.mempoolBlockIndex = parseInt(params.get('id'), 10) || 0;
|
switchMap((params: ParamMap) => {
|
||||||
this.stateService.markBlock$.next({ mempoolBlockIndex: this.mempoolBlockIndex });
|
this.mempoolBlockIndex = parseInt(params.get('id'), 10) || 0;
|
||||||
return this.stateService.mempoolBlocks$
|
return this.stateService.mempoolBlocks$
|
||||||
.pipe(
|
.pipe(
|
||||||
map((mempoolBlocks) => mempoolBlocks[this.mempoolBlockIndex])
|
map((mempoolBlocks) => {
|
||||||
);
|
while (!mempoolBlocks[this.mempoolBlockIndex]) {
|
||||||
})
|
this.mempoolBlockIndex--;
|
||||||
)
|
}
|
||||||
.subscribe((mempoolBlock) => {
|
return mempoolBlocks[this.mempoolBlockIndex];
|
||||||
this.mempoolBlock = mempoolBlock;
|
})
|
||||||
});
|
);
|
||||||
|
}),
|
||||||
|
tap(() => {
|
||||||
|
this.stateService.markBlock$.next({ mempoolBlockIndex: this.mempoolBlockIndex });
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user