Fix duplicate api call to audit status
This commit is contained in:
parent
1a2844ffdf
commit
5b93d39d73
@ -1,6 +1,6 @@
|
|||||||
import { Component, OnInit, ChangeDetectionStrategy, Input } from '@angular/core';
|
import { Component, OnInit, ChangeDetectionStrategy, Input } from '@angular/core';
|
||||||
import { Observable, combineLatest, of, timer } from 'rxjs';
|
import { Observable, Subject, combineLatest, of, timer } from 'rxjs';
|
||||||
import { delayWhen, filter, map, share, shareReplay, switchMap, tap, throttleTime } from 'rxjs/operators';
|
import { delayWhen, filter, map, share, shareReplay, switchMap, takeUntil, tap, throttleTime } from 'rxjs/operators';
|
||||||
import { ApiService } from '../../../services/api.service';
|
import { ApiService } from '../../../services/api.service';
|
||||||
import { Env, StateService } from '../../../services/state.service';
|
import { Env, StateService } from '../../../services/state.service';
|
||||||
import { AuditStatus, CurrentPegs, FederationAddress } from '../../../interfaces/node-api.interface';
|
import { AuditStatus, CurrentPegs, FederationAddress } from '../../../interfaces/node-api.interface';
|
||||||
@ -30,6 +30,8 @@ export class FederationAddressesListComponent implements OnInit {
|
|||||||
lastPegAmount: string = '';
|
lastPegAmount: string = '';
|
||||||
isLoad: boolean = true;
|
isLoad: boolean = true;
|
||||||
|
|
||||||
|
private destroy$ = new Subject();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
public stateService: StateService,
|
public stateService: StateService,
|
||||||
@ -44,6 +46,7 @@ export class FederationAddressesListComponent implements OnInit {
|
|||||||
if (!this.widget) {
|
if (!this.widget) {
|
||||||
this.websocketService.want(['blocks']);
|
this.websocketService.want(['blocks']);
|
||||||
this.auditStatus$ = this.stateService.blocks$.pipe(
|
this.auditStatus$ = this.stateService.blocks$.pipe(
|
||||||
|
takeUntil(this.destroy$),
|
||||||
throttleTime(40000),
|
throttleTime(40000),
|
||||||
delayWhen(_ => this.isLoad ? timer(0) : timer(2000)),
|
delayWhen(_ => this.isLoad ? timer(0) : timer(2000)),
|
||||||
tap(() => this.isLoad = false),
|
tap(() => this.isLoad = false),
|
||||||
@ -92,7 +95,11 @@ export class FederationAddressesListComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
this.destroy$.next(1);
|
||||||
|
this.destroy$.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
pageChange(page: number): void {
|
pageChange(page: number): void {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Component, OnInit, ChangeDetectionStrategy, Input } from '@angular/core';
|
import { Component, OnInit, ChangeDetectionStrategy, Input } from '@angular/core';
|
||||||
import { Observable, combineLatest, of, timer } from 'rxjs';
|
import { Observable, Subject, combineLatest, of, timer } from 'rxjs';
|
||||||
import { delayWhen, filter, map, share, shareReplay, switchMap, tap, throttleTime } from 'rxjs/operators';
|
import { delayWhen, filter, map, share, shareReplay, switchMap, takeUntil, tap, throttleTime } from 'rxjs/operators';
|
||||||
import { ApiService } from '../../../services/api.service';
|
import { ApiService } from '../../../services/api.service';
|
||||||
import { Env, StateService } from '../../../services/state.service';
|
import { Env, StateService } from '../../../services/state.service';
|
||||||
import { AuditStatus, CurrentPegs, FederationUtxo } from '../../../interfaces/node-api.interface';
|
import { AuditStatus, CurrentPegs, FederationUtxo } from '../../../interfaces/node-api.interface';
|
||||||
@ -30,6 +30,8 @@ export class FederationUtxosListComponent implements OnInit {
|
|||||||
lastPegAmount: string = '';
|
lastPegAmount: string = '';
|
||||||
isLoad: boolean = true;
|
isLoad: boolean = true;
|
||||||
|
|
||||||
|
private destroy$ = new Subject();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
public stateService: StateService,
|
public stateService: StateService,
|
||||||
@ -44,6 +46,7 @@ export class FederationUtxosListComponent implements OnInit {
|
|||||||
if (!this.widget) {
|
if (!this.widget) {
|
||||||
this.websocketService.want(['blocks']);
|
this.websocketService.want(['blocks']);
|
||||||
this.auditStatus$ = this.stateService.blocks$.pipe(
|
this.auditStatus$ = this.stateService.blocks$.pipe(
|
||||||
|
takeUntil(this.destroy$),
|
||||||
throttleTime(40000),
|
throttleTime(40000),
|
||||||
delayWhen(_ => this.isLoad ? timer(0) : timer(2000)),
|
delayWhen(_ => this.isLoad ? timer(0) : timer(2000)),
|
||||||
tap(() => this.isLoad = false),
|
tap(() => this.isLoad = false),
|
||||||
@ -92,7 +95,11 @@ export class FederationUtxosListComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
this.destroy$.next(1);
|
||||||
|
this.destroy$.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
pageChange(page: number): void {
|
pageChange(page: number): void {
|
||||||
|
@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
|||||||
import { SeoService } from '../../../services/seo.service';
|
import { SeoService } from '../../../services/seo.service';
|
||||||
import { WebsocketService } from '../../../services/websocket.service';
|
import { WebsocketService } from '../../../services/websocket.service';
|
||||||
import { StateService } from '../../../services/state.service';
|
import { StateService } from '../../../services/state.service';
|
||||||
import { Observable, combineLatest, delayWhen, filter, interval, map, of, share, shareReplay, startWith, switchMap, tap, throttleTime, timer } from 'rxjs';
|
import { Observable, Subject, combineLatest, delayWhen, filter, interval, map, of, share, shareReplay, startWith, switchMap, takeUntil, tap, throttleTime, timer } from 'rxjs';
|
||||||
import { ApiService } from '../../../services/api.service';
|
import { ApiService } from '../../../services/api.service';
|
||||||
import { AuditStatus, CurrentPegs, FederationAddress, FederationUtxo } from '../../../interfaces/node-api.interface';
|
import { AuditStatus, CurrentPegs, FederationAddress, FederationUtxo } from '../../../interfaces/node-api.interface';
|
||||||
|
|
||||||
@ -29,6 +29,7 @@ export class ReservesAuditDashboardComponent implements OnInit {
|
|||||||
private lastPegAmount: string = '';
|
private lastPegAmount: string = '';
|
||||||
private lastReservesBlockUpdate: number = 0;
|
private lastReservesBlockUpdate: number = 0;
|
||||||
|
|
||||||
|
private destroy$ = new Subject();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private seoService: SeoService,
|
private seoService: SeoService,
|
||||||
@ -43,11 +44,12 @@ export class ReservesAuditDashboardComponent implements OnInit {
|
|||||||
this.websocketService.want(['blocks', 'mempool-blocks']);
|
this.websocketService.want(['blocks', 'mempool-blocks']);
|
||||||
|
|
||||||
this.auditStatus$ = this.stateService.blocks$.pipe(
|
this.auditStatus$ = this.stateService.blocks$.pipe(
|
||||||
|
takeUntil(this.destroy$),
|
||||||
throttleTime(40000),
|
throttleTime(40000),
|
||||||
delayWhen(_ => this.isLoad ? timer(0) : timer(2000)),
|
delayWhen(_ => this.isLoad ? timer(0) : timer(2000)),
|
||||||
tap(() => this.isLoad = false),
|
tap(() => this.isLoad = false),
|
||||||
switchMap(() => this.apiService.federationAuditSynced$()),
|
switchMap(() => this.apiService.federationAuditSynced$()),
|
||||||
shareReplay(1)
|
shareReplay(1),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.currentPeg$ = this.auditStatus$.pipe(
|
this.currentPeg$ = this.auditStatus$.pipe(
|
||||||
@ -177,4 +179,9 @@ export class ReservesAuditDashboardComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
this.destroy$.next(1);
|
||||||
|
this.destroy$.complete();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { AfterViewInit, ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
|
import { AfterViewInit, ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { combineLatest, EMPTY, merge, Observable, of, Subscription, timer } from 'rxjs';
|
import { combineLatest, EMPTY, merge, Observable, of, Subject, Subscription, timer } from 'rxjs';
|
||||||
import { catchError, delayWhen, filter, map, scan, share, shareReplay, startWith, switchMap, tap, throttleTime } from 'rxjs/operators';
|
import { catchError, delayWhen, filter, map, scan, share, shareReplay, startWith, switchMap, takeUntil, tap, throttleTime } from 'rxjs/operators';
|
||||||
import { AuditStatus, BlockExtended, CurrentPegs, OptimizedMempoolStats } from '../interfaces/node-api.interface';
|
import { AuditStatus, BlockExtended, CurrentPegs, 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';
|
||||||
@ -60,6 +60,8 @@ export class DashboardComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
private lastPegAmount: string = '';
|
private lastPegAmount: string = '';
|
||||||
private lastReservesBlockUpdate: number = 0;
|
private lastReservesBlockUpdate: number = 0;
|
||||||
|
|
||||||
|
private destroy$ = new Subject();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public stateService: StateService,
|
public stateService: StateService,
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
@ -74,6 +76,8 @@ export class DashboardComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.currencySubscription.unsubscribe();
|
this.currencySubscription.unsubscribe();
|
||||||
this.websocketService.stopTrackRbfSummary();
|
this.websocketService.stopTrackRbfSummary();
|
||||||
|
this.destroy$.next(1);
|
||||||
|
this.destroy$.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@ -215,12 +219,12 @@ export class DashboardComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
|
|
||||||
if (this.stateService.network === 'liquid' || this.stateService.network === 'liquidtestnet') {
|
if (this.stateService.network === 'liquid' || this.stateService.network === 'liquidtestnet') {
|
||||||
this.auditStatus$ = this.stateService.blocks$.pipe(
|
this.auditStatus$ = this.stateService.blocks$.pipe(
|
||||||
|
takeUntil(this.destroy$),
|
||||||
throttleTime(40000),
|
throttleTime(40000),
|
||||||
delayWhen(_ => this.isLoad ? timer(0) : timer(2000)),
|
delayWhen(_ => this.isLoad ? timer(0) : timer(2000)),
|
||||||
tap(() => this.isLoad = false),
|
tap(() => this.isLoad = false),
|
||||||
switchMap(() => this.apiService.federationAuditSynced$()),
|
switchMap(() => this.apiService.federationAuditSynced$()),
|
||||||
shareReplay(1),
|
shareReplay(1)
|
||||||
share()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
////////// Pegs historical data //////////
|
////////// Pegs historical data //////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user