Add throttleTime to avoid too frequent calls to backend

This commit is contained in:
natsee 2024-01-22 14:19:01 +01:00
parent 81a09e9dba
commit 8f7cd70882
No known key found for this signature in database
GPG Key ID: 233CF3150A89BED8
2 changed files with 4 additions and 2 deletions

View File

@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { SeoService } from '../../../services/seo.service';
import { WebsocketService } from '../../../services/websocket.service';
import { StateService } from '../../../services/state.service';
import { Observable, concat, delay, filter, share, skip, switchMap, tap } from 'rxjs';
import { Observable, concat, delay, filter, share, skip, switchMap, tap, throttleTime } from 'rxjs';
import { ApiService } from '../../../services/api.service';
import { AuditStatus, CurrentPegs, FederationAddress, FederationUtxo } from '../../../interfaces/node-api.interface';
@ -38,6 +38,7 @@ export class ReservesAuditDashboardComponent implements OnInit {
this.apiService.federationAuditSynced$().pipe(share()),
this.stateService.blocks$.pipe(
skip(1),
throttleTime(40000),
delay(2000),
switchMap(() => this.apiService.federationAuditSynced$()),
share()

View File

@ -1,6 +1,6 @@
import { AfterViewInit, ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
import { combineLatest, concat, EMPTY, interval, merge, Observable, of, Subscription } from 'rxjs';
import { catchError, delay, filter, map, mergeMap, scan, share, skip, startWith, switchMap, tap } from 'rxjs/operators';
import { catchError, delay, filter, map, mergeMap, scan, share, skip, startWith, switchMap, tap, throttleTime } from 'rxjs/operators';
import { AuditStatus, BlockExtended, CurrentPegs, OptimizedMempoolStats } from '../interfaces/node-api.interface';
import { MempoolInfo, TransactionStripped, ReplacementInfo } from '../interfaces/websocket.interface';
import { ApiService } from '../services/api.service';
@ -252,6 +252,7 @@ export class DashboardComponent implements OnInit, OnDestroy, AfterViewInit {
this.apiService.federationAuditSynced$().pipe(share()),
this.stateService.blocks$.pipe(
skip(1),
throttleTime(40000),
delay(2000),
switchMap(() => this.apiService.federationAuditSynced$()),
share()