Add numBlocks param
This commit is contained in:
parent
ec8fc53dcb
commit
d69cdacd5e
@ -1,5 +1,5 @@
|
|||||||
<div class="blocks" [class.wrap]="wrapBlocks">
|
<div class="blocks" [class.wrap]="wrapBlocks">
|
||||||
<ng-container *ngFor="let i of [0,1,2,3,4,5,6,7]">
|
<ng-container *ngFor="let i of blockIndices">
|
||||||
<div class="block-wrapper" [style]="wrapperStyle">
|
<div class="block-wrapper" [style]="wrapperStyle">
|
||||||
<div class="block-container" [style]="containerStyle">
|
<div class="block-container" [style]="containerStyle">
|
||||||
<app-block-overview-graph
|
<app-block-overview-graph
|
||||||
|
@ -56,6 +56,8 @@ export class EightBlocksComponent implements OnInit, OnDestroy {
|
|||||||
queryParamsSubscription: Subscription;
|
queryParamsSubscription: Subscription;
|
||||||
graphChangeSubscription: Subscription;
|
graphChangeSubscription: Subscription;
|
||||||
|
|
||||||
|
numBlocks: number = 8;
|
||||||
|
blockIndices: number[] = [...Array(8).keys()];
|
||||||
autofit: boolean = false;
|
autofit: boolean = false;
|
||||||
padding: number = 0;
|
padding: number = 0;
|
||||||
wrapBlocks: boolean = false;
|
wrapBlocks: boolean = false;
|
||||||
@ -96,12 +98,9 @@ export class EightBlocksComponent implements OnInit, OnDestroy {
|
|||||||
this.websocketService.want(['blocks']);
|
this.websocketService.want(['blocks']);
|
||||||
this.network = this.stateService.network;
|
this.network = this.stateService.network;
|
||||||
|
|
||||||
this.blocksSubscription = this.stateService.blocks$
|
|
||||||
.subscribe((blocks) => {
|
|
||||||
this.handleNewBlock(blocks);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.queryParamsSubscription = this.route.queryParams.subscribe((params) => {
|
this.queryParamsSubscription = this.route.queryParams.subscribe((params) => {
|
||||||
|
this.numBlocks = Number.isInteger(Number(params.numBlocks)) ? Number(params.numBlocks) : 8;
|
||||||
|
this.blockIndices = [...Array(this.numBlocks).keys()];
|
||||||
this.autofit = params.autofit === 'true';
|
this.autofit = params.autofit === 'true';
|
||||||
this.padding = Number.isInteger(Number(params.padding)) ? Number(params.padding) : 0;
|
this.padding = Number.isInteger(Number(params.padding)) ? Number(params.padding) : 0;
|
||||||
this.blockWidth = Number.isInteger(Number(params.blockWidth)) ? Number(params.blockWidth) : 1080;
|
this.blockWidth = Number.isInteger(Number(params.blockWidth)) ? Number(params.blockWidth) : 1080;
|
||||||
@ -124,11 +123,18 @@ export class EightBlocksComponent implements OnInit, OnDestroy {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (params.test === 'true') {
|
if (params.test === 'true') {
|
||||||
this.blocksSubscription.unsubscribe();
|
if (this.blocksSubscription) {
|
||||||
|
this.blocksSubscription.unsubscribe();
|
||||||
|
}
|
||||||
this.blocksSubscription = (new Subject<BlockExtended[]>()).subscribe((blocks) => {
|
this.blocksSubscription = (new Subject<BlockExtended[]>()).subscribe((blocks) => {
|
||||||
this.handleNewBlock(blocks);
|
this.handleNewBlock(blocks.slice(0, this.numBlocks));
|
||||||
});
|
});
|
||||||
this.shiftTestBlocks();
|
this.shiftTestBlocks();
|
||||||
|
} else if (!this.blocksSubscription) {
|
||||||
|
this.blocksSubscription = this.stateService.blocks$
|
||||||
|
.subscribe((blocks) => {
|
||||||
|
this.handleNewBlock(blocks.slice(0, this.numBlocks));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -146,7 +152,9 @@ export class EightBlocksComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.stateService.markBlock$.next({});
|
this.stateService.markBlock$.next({});
|
||||||
this.blocksSubscription?.unsubscribe();
|
if (this.blocksSubscription) {
|
||||||
|
this.blocksSubscription?.unsubscribe();
|
||||||
|
}
|
||||||
this.cacheBlocksSubscription?.unsubscribe();
|
this.cacheBlocksSubscription?.unsubscribe();
|
||||||
this.networkChangedSubscription?.unsubscribe();
|
this.networkChangedSubscription?.unsubscribe();
|
||||||
this.queryParamsSubscription?.unsubscribe();
|
this.queryParamsSubscription?.unsubscribe();
|
||||||
@ -155,7 +163,7 @@ export class EightBlocksComponent implements OnInit, OnDestroy {
|
|||||||
shiftTestBlocks(): void {
|
shiftTestBlocks(): void {
|
||||||
const sub = this.apiService.getBlocks$(this.testHeight).subscribe(result => {
|
const sub = this.apiService.getBlocks$(this.testHeight).subscribe(result => {
|
||||||
sub.unsubscribe();
|
sub.unsubscribe();
|
||||||
this.handleNewBlock(result);
|
this.handleNewBlock(result.slice(0, this.numBlocks));
|
||||||
this.testHeight++;
|
this.testHeight++;
|
||||||
clearTimeout(this.testShiftTimeout);
|
clearTimeout(this.testShiftTimeout);
|
||||||
this.testShiftTimeout = window.setTimeout(() => { this.shiftTestBlocks(); }, 10000);
|
this.testShiftTimeout = window.setTimeout(() => { this.shiftTestBlocks(); }, 10000);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user