Fix concurrent asynchronous calls. (#675)
* Fix concurrent asynchronous calls. * Remove test without mempool info websocket. * Remove isloading$ variable.
This commit is contained in:
parent
837e714b1f
commit
8b0d1db776
@ -1,4 +1,4 @@
|
|||||||
import { emitMempoolInfo } from "../../support/websocket";
|
import { emitMempoolInfo, emitWithoutMempoolInfo } from "../../support/websocket";
|
||||||
|
|
||||||
describe('Mainnet', () => {
|
describe('Mainnet', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -51,6 +51,7 @@ describe('Mainnet', () => {
|
|||||||
loaded: true
|
loaded: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cy.get(':nth-child(1) > #bitcoin-block-0').should('not.exist');
|
cy.get(':nth-child(1) > #bitcoin-block-0').should('not.exist');
|
||||||
cy.get(':nth-child(2) > #bitcoin-block-0').should('not.exist');
|
cy.get(':nth-child(2) > #bitcoin-block-0').should('not.exist');
|
||||||
cy.get(':nth-child(3) > #bitcoin-block-0').should('not.exist');
|
cy.get(':nth-child(3) > #bitcoin-block-0').should('not.exist');
|
||||||
|
@ -70,15 +70,15 @@ export const emitMempoolInfo = ({
|
|||||||
default:
|
default:
|
||||||
win.mockSocket.send('{"action":"init"}');
|
win.mockSocket.send('{"action":"init"}');
|
||||||
win.mockSocket.send('{"action":"want","data":["blocks","stats","mempool-blocks","live-2h-chart"]}');
|
win.mockSocket.send('{"action":"want","data":["blocks","stats","mempool-blocks","live-2h-chart"]}');
|
||||||
cy.readFile('cypress/fixtures/mainnet_mempoolInfo.json', 'ascii').then((fixture) => {
|
|
||||||
win.mockSocket.send(JSON.stringify(fixture));
|
|
||||||
});
|
|
||||||
win.mockSocket.send('{"conversions":{"USD":32365.338815782445}}');
|
win.mockSocket.send('{"conversions":{"USD":32365.338815782445}}');
|
||||||
cy.readFile('cypress/fixtures/mainnet_live2hchart.json', 'ascii').then((fixture) => {
|
cy.readFile('cypress/fixtures/mainnet_live2hchart.json', 'ascii').then((fixture) => {
|
||||||
win.mockSocket.send(JSON.stringify(fixture));
|
win.mockSocket.send(JSON.stringify(fixture));
|
||||||
});
|
});
|
||||||
|
cy.readFile('cypress/fixtures/mainnet_mempoolInfo.json', 'ascii').then((fixture) => {
|
||||||
|
win.mockSocket.send(JSON.stringify(fixture));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cy.waitForSkeletonGone();
|
cy.waitForSkeletonGone();
|
||||||
return cy.get('#mempool-block-0');
|
return cy.get('#mempool-block-0');
|
||||||
};
|
};
|
@ -1,4 +1,4 @@
|
|||||||
<div class="blocks-container" *ngIf="(isLoading$ | async) === false">
|
<div class="blocks-container" *ngIf="loadingBlocks">
|
||||||
<div *ngFor="let block of blocks; let i = index; trackBy: trackByBlocksFn" >
|
<div *ngFor="let block of blocks; let i = index; trackBy: trackByBlocksFn" >
|
||||||
<div class="text-center bitcoin-block mined-block" id="bitcoin-block-{{ block.height }}" [ngStyle]="blockStyles[i]">
|
<div class="text-center bitcoin-block mined-block" id="bitcoin-block-{{ block.height }}" [ngStyle]="blockStyles[i]">
|
||||||
<a [routerLink]="['/block/' | relativeUrl, block.id]" [state]="{ data: { block: block } }" class="blockLink"> </a>
|
<a [routerLink]="['/block/' | relativeUrl, block.id]" [state]="{ data: { block: block } }" class="blockLink"> </a>
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<div [hidden]="!arrowVisible" id="arrow-up" [style.transition]="transition" [ngStyle]="{'left': arrowLeftPx + 'px' }"></div>
|
<div [hidden]="!arrowVisible" id="arrow-up" [style.transition]="transition" [ngStyle]="{'left': arrowLeftPx + 'px' }"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="blocks-container" *ngIf="(isLoading$ | async) === true">
|
<div class="blocks-container" *ngIf="!loadingBlocks">
|
||||||
<div class="flashing">
|
<div class="flashing">
|
||||||
<div *ngFor="let block of blocks; let i = index; trackBy: trackByBlocksFn" >
|
<div *ngFor="let block of blocks; let i = index; trackBy: trackByBlocksFn" >
|
||||||
<div class="text-center bitcoin-block mined-block" id="bitcoin-block-{{ block.height }}" [ngStyle]="blockStyles[i]"></div>
|
<div class="text-center bitcoin-block mined-block" id="bitcoin-block-{{ block.height }}" [ngStyle]="blockStyles[i]"></div>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Component, OnInit, OnDestroy, ChangeDetectionStrategy, ChangeDetectorRef, Input } from '@angular/core';
|
import { Component, OnInit, OnDestroy, ChangeDetectionStrategy, ChangeDetectorRef, Input } from '@angular/core';
|
||||||
import { Subscription, Observable } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { Block } from 'src/app/interfaces/electrs.interface';
|
import { Block } from 'src/app/interfaces/electrs.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';
|
||||||
@ -11,8 +11,7 @@ import { Router } from '@angular/router';
|
|||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class BlockchainBlocksComponent implements OnInit, OnDestroy {
|
export class BlockchainBlocksComponent implements OnInit, OnDestroy {
|
||||||
@Input() isLoading$: Observable<boolean>;
|
|
||||||
|
|
||||||
network = '';
|
network = '';
|
||||||
blocks: Block[] = this.mountEmptyBlocks();
|
blocks: Block[] = this.mountEmptyBlocks();
|
||||||
markHeight: number;
|
markHeight: number;
|
||||||
@ -23,6 +22,7 @@ export class BlockchainBlocksComponent implements OnInit, OnDestroy {
|
|||||||
blockStyles = [];
|
blockStyles = [];
|
||||||
interval: any;
|
interval: any;
|
||||||
tabHidden = false;
|
tabHidden = false;
|
||||||
|
loadingBlocks = false;
|
||||||
|
|
||||||
arrowVisible = false;
|
arrowVisible = false;
|
||||||
arrowLeftPx = 30;
|
arrowLeftPx = 30;
|
||||||
@ -54,6 +54,8 @@ export class BlockchainBlocksComponent implements OnInit, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.loadingBlocks = true;
|
||||||
|
|
||||||
if (this.blocks.length && block.height !== this.blocks[0].height + 1) {
|
if (this.blocks.length && block.height !== this.blocks[0].height + 1) {
|
||||||
this.blocks = [];
|
this.blocks = [];
|
||||||
this.blocksFilled = false;
|
this.blocksFilled = false;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<div class="text-center" class="blockchain-wrapper">
|
<div class="text-center" class="blockchain-wrapper">
|
||||||
<div class="position-container">
|
<div class="position-container">
|
||||||
<span>
|
<span>
|
||||||
<app-mempool-blocks [isLoading$]="isLoading$"></app-mempool-blocks>
|
<app-mempool-blocks></app-mempool-blocks>
|
||||||
<app-blockchain-blocks [isLoading$]="isLoading$"></app-blockchain-blocks>
|
<app-blockchain-blocks></app-blockchain-blocks>
|
||||||
<div id="divider"></div>
|
<div id="divider"></div>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,21 +1,11 @@
|
|||||||
import { Component, OnInit, OnDestroy, ChangeDetectionStrategy } from '@angular/core';
|
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
||||||
import { StateService } from 'src/app/services/state.service';
|
|
||||||
import { Subscription, Observable } from 'rxjs';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-blockchain',
|
selector: 'app-blockchain',
|
||||||
templateUrl: './blockchain.component.html',
|
templateUrl: './blockchain.component.html',
|
||||||
styleUrls: ['./blockchain.component.scss'],
|
styleUrls: ['./blockchain.component.scss'],
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class BlockchainComponent implements OnInit {
|
export class BlockchainComponent {
|
||||||
isLoading$: Observable<boolean>;
|
|
||||||
|
|
||||||
constructor(
|
constructor() { }
|
||||||
private stateService: StateService,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.isLoading$ = this.stateService.isLoadingWebSocket$;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<div class="mempool-blocks-container" *ngIf="(isLoading$ | async) === false">
|
<div class="mempool-blocks-container">
|
||||||
<div class="flashing" *ngIf="(timeAvg$ | async) as timeAvg;">
|
<div class="flashing" *ngIf="(timeAvg$ | async) as timeAvg;">
|
||||||
<ng-template ngFor let-projectedBlock [ngForOf]="mempoolBlocks$ | async" let-i="index" [ngForTrackBy]="trackByFn">
|
<ng-template ngFor let-projectedBlock [ngForOf]="mempoolBlocks$ | async" let-i="index" [ngForTrackBy]="trackByFn">
|
||||||
<div class="bitcoin-block text-center mempool-block" id="mempool-block-{{ i }}" [ngStyle]="mempoolBlockStyles[i]">
|
<div class="bitcoin-block text-center mempool-block" id="mempool-block-{{ i }}" [ngStyle]="mempoolBlockStyles[i]">
|
||||||
@ -38,7 +38,7 @@
|
|||||||
<div *ngIf="arrowVisible" id="arrow-up" [ngStyle]="{'right': rightPosition + 75 + 'px', transition: transition }"></div>
|
<div *ngIf="arrowVisible" id="arrow-up" [ngStyle]="{'right': rightPosition + 75 + 'px', transition: transition }"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mempool-blocks-container" *ngIf="(isLoading$ | async) === true">
|
<div class="mempool-blocks-container" *ngIf="loadingMempoolBlocks === true">
|
||||||
<div class="flashing">
|
<div class="flashing">
|
||||||
<ng-template ngFor let-projectedBlock [ngForOf]="mempoolBlocks" let-i="index" [ngForTrackBy]="trackByFn">
|
<ng-template ngFor let-projectedBlock [ngForOf]="mempoolBlocks" let-i="index" [ngForTrackBy]="trackByFn">
|
||||||
<div class="bitcoin-block text-center mempool-block" id="mempool-block-{{ i }}" [ngStyle]="mempoolBlockStyles[i]"></div>
|
<div class="bitcoin-block text-center mempool-block" id="mempool-block-{{ i }}" [ngStyle]="mempoolBlockStyles[i]"></div>
|
||||||
|
@ -13,7 +13,6 @@ import { feeLevels, mempoolFeeColors } from 'src/app/app.constants';
|
|||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class MempoolBlocksComponent implements OnInit, OnDestroy {
|
export class MempoolBlocksComponent implements OnInit, OnDestroy {
|
||||||
@Input() isLoading$: Observable<boolean>;
|
|
||||||
|
|
||||||
mempoolBlocks: MempoolBlock[] = this.mountEmptyBlocks();
|
mempoolBlocks: MempoolBlock[] = this.mountEmptyBlocks();
|
||||||
mempoolBlocks$: Observable<MempoolBlock[]>;
|
mempoolBlocks$: Observable<MempoolBlock[]>;
|
||||||
@ -31,6 +30,7 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
|
|||||||
blockPadding = 30;
|
blockPadding = 30;
|
||||||
arrowVisible = false;
|
arrowVisible = false;
|
||||||
tabHidden = false;
|
tabHidden = false;
|
||||||
|
loadingMempoolBlocks = true;
|
||||||
|
|
||||||
rightPosition = 0;
|
rightPosition = 0;
|
||||||
transition = '2s';
|
transition = '2s';
|
||||||
@ -106,6 +106,7 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
|
|||||||
timeAvgMins += Math.abs(timeAvgDiff);
|
timeAvgMins += Math.abs(timeAvgDiff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.loadingMempoolBlocks = false;
|
||||||
return timeAvgMins * 60 * 1000;
|
return timeAvgMins * 60 * 1000;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
|
|
||||||
<div class="blockchain-wrapper">
|
<div class="blockchain-wrapper">
|
||||||
<div class="position-container">
|
<div class="position-container">
|
||||||
<app-mempool-blocks [isLoading$]="isLoading$"></app-mempool-blocks>
|
<app-mempool-blocks></app-mempool-blocks>
|
||||||
<app-blockchain-blocks [isLoading$]="isLoading$"></app-blockchain-blocks>
|
<app-blockchain-blocks></app-blockchain-blocks>
|
||||||
<div id="divider"></div>
|
<div id="divider"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,7 +12,6 @@ import { Observable } from 'rxjs';
|
|||||||
styleUrls: ['./television.component.scss']
|
styleUrls: ['./television.component.scss']
|
||||||
})
|
})
|
||||||
export class TelevisionComponent implements OnInit {
|
export class TelevisionComponent implements OnInit {
|
||||||
isLoading$: Observable<boolean>;
|
|
||||||
|
|
||||||
mempoolStats: OptimizedMempoolStats[] = [];
|
mempoolStats: OptimizedMempoolStats[] = [];
|
||||||
mempoolVsizeFeesData: any;
|
mempoolVsizeFeesData: any;
|
||||||
@ -27,7 +26,6 @@ export class TelevisionComponent implements OnInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.seoService.setTitle($localize`:@@46ce8155c9ab953edeec97e8950b5a21e67d7c4e:TV view`);
|
this.seoService.setTitle($localize`:@@46ce8155c9ab953edeec97e8950b5a21e67d7c4e:TV view`);
|
||||||
this.websocketService.want(['blocks', 'live-2h-chart', 'mempool-blocks']);
|
this.websocketService.want(['blocks', 'live-2h-chart', 'mempool-blocks']);
|
||||||
this.isLoading$ = this.stateService.isLoadingWebSocket$;
|
|
||||||
|
|
||||||
this.apiService.list2HStatistics$()
|
this.apiService.list2HStatistics$()
|
||||||
.subscribe((mempoolStats) => {
|
.subscribe((mempoolStats) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user