Merge pull request #4059 from mempool/mononaut/connection-state
fix websocket connection state observable
This commit is contained in:
commit
14c86b84b8
@ -1,6 +1,6 @@
|
|||||||
import { AfterViewInit, ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
|
import { AfterViewInit, ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { combineLatest, merge, Observable, of, Subscription } from 'rxjs';
|
import { combineLatest, merge, Observable, of, Subscription } from 'rxjs';
|
||||||
import { filter, map, scan, share, switchMap, tap } from 'rxjs/operators';
|
import { catchError, filter, map, scan, share, switchMap, tap } from 'rxjs/operators';
|
||||||
import { BlockExtended, OptimizedMempoolStats } from '../interfaces/node-api.interface';
|
import { BlockExtended, OptimizedMempoolStats } from '../interfaces/node-api.interface';
|
||||||
import { MempoolInfo, TransactionStripped, ReplacementInfo } from '../interfaces/websocket.interface';
|
import { MempoolInfo, TransactionStripped, ReplacementInfo } from '../interfaces/websocket.interface';
|
||||||
import { ApiService } from '../services/api.service';
|
import { ApiService } from '../services/api.service';
|
||||||
@ -171,7 +171,11 @@ export class DashboardComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
this.mempoolStats$ = this.stateService.connectionState$
|
this.mempoolStats$ = this.stateService.connectionState$
|
||||||
.pipe(
|
.pipe(
|
||||||
filter((state) => state === 2),
|
filter((state) => state === 2),
|
||||||
switchMap(() => this.apiService.list2HStatistics$()),
|
switchMap(() => this.apiService.list2HStatistics$().pipe(
|
||||||
|
catchError((e) => {
|
||||||
|
return of(null);
|
||||||
|
})
|
||||||
|
)),
|
||||||
switchMap((mempoolStats) => {
|
switchMap((mempoolStats) => {
|
||||||
return merge(
|
return merge(
|
||||||
this.stateService.live2Chart$
|
this.stateService.live2Chart$
|
||||||
@ -186,10 +190,14 @@ export class DashboardComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
map((mempoolStats) => {
|
map((mempoolStats) => {
|
||||||
return {
|
if (mempoolStats) {
|
||||||
mempool: mempoolStats,
|
return {
|
||||||
weightPerSecond: this.handleNewMempoolData(mempoolStats.concat([])),
|
mempool: mempoolStats,
|
||||||
};
|
weightPerSecond: this.handleNewMempoolData(mempoolStats.concat([])),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
share(),
|
share(),
|
||||||
);
|
);
|
||||||
|
@ -113,7 +113,7 @@ export class WebsocketService {
|
|||||||
this.stateService.connectionState$.next(2);
|
this.stateService.connectionState$.next(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.stateService.connectionState$.value === 1) {
|
if (this.stateService.connectionState$.value !== 2) {
|
||||||
this.stateService.connectionState$.next(2);
|
this.stateService.connectionState$.next(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user