From 6a7273cbd241d15499276ce58a34af9ec53da2a0 Mon Sep 17 00:00:00 2001 From: Wouter <171353+wouterter@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:14:54 +0200 Subject: [PATCH 1/2] Removed console.log --- src/app/pages/privacy-policy/privacy-policy.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/pages/privacy-policy/privacy-policy.component.ts b/src/app/pages/privacy-policy/privacy-policy.component.ts index 4f4a992..d1af671 100644 --- a/src/app/pages/privacy-policy/privacy-policy.component.ts +++ b/src/app/pages/privacy-policy/privacy-policy.component.ts @@ -37,7 +37,6 @@ export class PrivacyPolicyComponent implements OnInit { this.http.get('assets/privacy-policy.html', {responseType: 'text'}).subscribe({ next: html => { this.safeHtml.next(this.sanitizer.sanitize(SecurityContext.HTML, html)); - console.log(this.safeHtml.value); }, error: (err) => { this.router.navigate(['/not-found']); From a9a265b0167efa3d8fe7f5b97c23d9794b8ec173 Mon Sep 17 00:00:00 2001 From: MG <287479+Kriekkop@users.noreply.github.com> Date: Thu, 21 Sep 2023 13:46:13 +0200 Subject: [PATCH 2/2] Fixed error #28. --- .../block-detail/block-detail.component.ts | 55 ++++++++++--------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/src/app/pages/network/explorer/block/block-detail/block-detail.component.ts b/src/app/pages/network/explorer/block/block-detail/block-detail.component.ts index 1875eb6..a78fa8b 100644 --- a/src/app/pages/network/explorer/block/block-detail/block-detail.component.ts +++ b/src/app/pages/network/explorer/block/block-detail/block-detail.component.ts @@ -19,9 +19,9 @@ import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core'; import { ActivatedRoute, Params } from '@angular/router'; import { NetworkService } from '../../../../../services/network.service'; -import { BehaviorSubject, combineLatest, Observable, of, Subject, take, timer } from 'rxjs'; +import { BehaviorSubject, combineLatest, Observable, of, startWith, Subject, take, timer } from 'rxjs'; import { Block } from '../../../../../services/block/block.harvester'; -import { catchError, filter, first, switchMap, takeUntil, takeWhile, tap } from 'rxjs/operators'; +import { catchError, distinctUntilChanged, filter, first, switchMap, takeUntil, takeWhile, tap } from 'rxjs/operators'; import { PolkadaptService } from '../../../../../services/polkadapt.service'; import { types as pst } from '@polkadapt/core'; @@ -34,8 +34,8 @@ import { types as pst } from '@polkadapt/core'; export class BlockDetailComponent implements OnInit, OnDestroy { private destroyer = new Subject(); block = new BehaviorSubject(null); - extrinsics = new BehaviorSubject([]); - events = new BehaviorSubject([]); + extrinsics: Observable; + events: Observable; headNumber = new BehaviorSubject(0); invalidHash = new BehaviorSubject(false); @@ -95,14 +95,13 @@ export class BlockDetailComponent implements OnInit, OnDestroy { ).subscribe(); - this.block.pipe( - filter((block): block is Block => Boolean(block && block.finalized === true)), - take(1) - ).subscribe({ - next: (block) => { - this.extrinsics.next([]); - if (block.countExtrinsics) { - timer(0, 1000).pipe( + this.extrinsics = this.block.pipe( + distinctUntilChanged((p, n) => Boolean(p && n + && p.number === n.number + && p.finalized === n.finalized)), + switchMap((block) => { + if (block && block.finalized && block.countExtrinsics) { + return timer(0, 1000).pipe( take(10), // Try it for 10 seconds. switchMap(() => this.pa.run().getExtrinsics({ blockNumber: block.number, @@ -111,15 +110,21 @@ export class BlockDetailComponent implements OnInit, OnDestroy { }, 300)), takeUntil(this.destroyer), takeWhile((extrinsics) => block.countExtrinsics! > extrinsics.length, true), - switchMap((obs) => obs.length ? combineLatest(obs) : of([])) - ).subscribe({ - next: (extrinsics: pst.Extrinsic[]) => this.extrinsics.next(extrinsics) - }); + switchMap((obs) => obs.length ? combineLatest(obs) : of([])), + startWith([]) + ) } + return of([]); + }) + ); - this.events.next([]); - if (block.countEvents) { - timer(0, 1000).pipe( + this.events = this.block.pipe( + distinctUntilChanged((p, n) => Boolean(p && n + && p.number === n.number + && p.finalized === n.finalized)), + switchMap((block) => { + if (block && block.finalized && block.countEvents) { + return timer(0, 1000).pipe( take(10), // Try it for 10 seconds. switchMap(() => this.pa.run().getEvents({ blockNumber: block.number, @@ -128,13 +133,13 @@ export class BlockDetailComponent implements OnInit, OnDestroy { }, 300)), takeUntil(this.destroyer), takeWhile((events) => block.countEvents! > events.length, true), - switchMap((obs) => obs.length ? combineLatest(obs) : of([])) - ).subscribe({ - next: (events: pst.Event[]) => this.events.next(events) - }); + switchMap((obs) => obs.length ? combineLatest(obs) : of([])), + startWith([]) + ) } - } - }) + return of([]); + }) + ); } ngOnDestroy(): void {