2020-03-22 11:44:36 +01:00
|
|
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
2020-03-17 15:53:20 +01:00
|
|
|
import { StateService } from 'src/app/services/state.service';
|
|
|
|
import { ActivatedRoute, ParamMap } from '@angular/router';
|
|
|
|
import { switchMap, map } from 'rxjs/operators';
|
|
|
|
import { MempoolBlock } from 'src/app/interfaces/websocket.interface';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-mempool-block',
|
|
|
|
templateUrl: './mempool-block.component.html',
|
|
|
|
styleUrls: ['./mempool-block.component.scss']
|
|
|
|
})
|
2020-03-22 11:44:36 +01:00
|
|
|
export class MempoolBlockComponent implements OnInit, OnDestroy {
|
2020-03-17 15:53:20 +01:00
|
|
|
mempoolBlockIndex: number;
|
|
|
|
mempoolBlock: MempoolBlock;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private route: ActivatedRoute,
|
|
|
|
private stateService: StateService,
|
|
|
|
) { }
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
this.route.paramMap.pipe(
|
|
|
|
switchMap((params: ParamMap) => {
|
|
|
|
this.mempoolBlockIndex = parseInt(params.get('id'), 10) || 0;
|
2020-03-22 11:44:36 +01:00
|
|
|
this.stateService.markBlock$.next({ mempoolBlockIndex: this.mempoolBlockIndex });
|
2020-03-17 15:53:20 +01:00
|
|
|
return this.stateService.mempoolBlocks$
|
|
|
|
.pipe(
|
|
|
|
map((mempoolBlocks) => mempoolBlocks[this.mempoolBlockIndex])
|
|
|
|
);
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.subscribe((mempoolBlock) => {
|
|
|
|
this.mempoolBlock = mempoolBlock;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-03-22 11:44:36 +01:00
|
|
|
ngOnDestroy(): void {
|
|
|
|
this.stateService.markBlock$.next({});
|
|
|
|
}
|
|
|
|
|
2020-03-17 15:53:20 +01:00
|
|
|
}
|