From 54451c9a8c754ecd880363c8d8184645aa78f255 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Tue, 16 Aug 2022 16:15:34 +0000 Subject: [PATCH] Fix sticky error state on block page --- .../app/components/block/block.component.ts | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/components/block/block.component.ts b/frontend/src/app/components/block/block.component.ts index 621956d20..4862e4e5c 100644 --- a/frontend/src/app/components/block/block.component.ts +++ b/frontend/src/app/components/block/block.component.ts @@ -4,7 +4,7 @@ import { ActivatedRoute, ParamMap, Router } from '@angular/router'; import { ElectrsApiService } from '../../services/electrs-api.service'; import { switchMap, tap, throttleTime, catchError, map, shareReplay, startWith, pairwise } from 'rxjs/operators'; import { Transaction, Vout } from '../../interfaces/electrs.interface'; -import { Observable, of, Subscription, asyncScheduler } from 'rxjs'; +import { Observable, of, Subscription, asyncScheduler, EMPTY } from 'rxjs'; import { StateService } from '../../services/state.service'; import { SeoService } from 'src/app/services/seo.service'; import { WebsocketService } from 'src/app/services/websocket.service'; @@ -142,8 +142,21 @@ export class BlockComponent implements OnInit, OnDestroy { this.location.replaceState( this.router.createUrlTree([(this.network ? '/' + this.network : '') + '/block/', hash]).toString() ); - return this.apiService.getBlock$(hash); - }) + return this.apiService.getBlock$(hash).pipe( + catchError((err) => { + this.error = err; + this.isLoadingBlock = false; + this.isLoadingOverview = false; + return EMPTY; + }) + ); + }), + catchError((err) => { + this.error = err; + this.isLoadingBlock = false; + this.isLoadingOverview = false; + return EMPTY; + }), ); } @@ -152,7 +165,14 @@ export class BlockComponent implements OnInit, OnDestroy { return of(blockInCache); } - return this.apiService.getBlock$(blockHash); + return this.apiService.getBlock$(blockHash).pipe( + catchError((err) => { + this.error = err; + this.isLoadingBlock = false; + this.isLoadingOverview = false; + return EMPTY; + }) + ); } }), tap((block: BlockExtended) => { @@ -168,7 +188,6 @@ export class BlockComponent implements OnInit, OnDestroy { this.block = block; this.blockHeight = block.height; - const direction = (this.lastBlockHeight < this.blockHeight) ? 'right' : 'left'; this.lastBlockHeight = this.blockHeight; this.nextBlockHeight = block.height + 1; this.setNextAndPreviousBlockLink();