diff --git a/frontend/src/app/components/blocks-list/blocks-list.component.ts b/frontend/src/app/components/blocks-list/blocks-list.component.ts index 324807628..2b54058e8 100644 --- a/frontend/src/app/components/blocks-list/blocks-list.component.ts +++ b/frontend/src/app/components/blocks-list/blocks-list.component.ts @@ -82,12 +82,12 @@ export class BlocksList implements OnInit { ), this.stateService.blocks$ .pipe( - switchMap((block) => { - if (block[0].height <= this.lastBlockHeight) { + switchMap((blocks) => { + if (blocks[0].height <= this.lastBlockHeight) { return [null]; // Return an empty stream so the last pipe is not executed } - this.lastBlockHeight = block[0].height; - return [block]; + this.lastBlockHeight = blocks[0].height; + return blocks; }) ) ]) diff --git a/frontend/src/app/dashboard/dashboard.component.ts b/frontend/src/app/dashboard/dashboard.component.ts index 74a48c74c..6cf487be6 100644 --- a/frontend/src/app/dashboard/dashboard.component.ts +++ b/frontend/src/app/dashboard/dashboard.component.ts @@ -135,23 +135,16 @@ export class DashboardComponent implements OnInit, OnDestroy { tap((blocks) => { this.latestBlockHeight = blocks[0].height; }), - scan((acc, [block]) => { - if (acc.find((b) => b.height == block.height)) { - return acc; - } - acc.unshift(block); - acc = acc.slice(0, 6); - + switchMap((blocks) => { if (this.stateService.env.MINING_DASHBOARD === true) { - for (const block of acc) { + for (const block of blocks) { // @ts-ignore: Need to add an extra field for the template block.extras.pool.logo = `/resources/mining-pools/` + block.extras.pool.name.toLowerCase().replace(' ', '').replace('.', '') + '.svg'; } } - - return acc; - }, []), + return of(blocks.slice(0, 6)); + }) ); this.transactions$ = this.stateService.transactions$ diff --git a/frontend/src/app/services/state.service.ts b/frontend/src/app/services/state.service.ts index a3392d738..f38600605 100644 --- a/frontend/src/app/services/state.service.ts +++ b/frontend/src/app/services/state.service.ts @@ -201,7 +201,7 @@ export class StateService { this.networkChanged$.subscribe((network) => { this.transactions$ = new ReplaySubject(6); - this.blocksSubject$ = new BehaviorSubject([]); + this.blocksSubject$.next([]); }); this.blockVSize = this.env.BLOCK_WEIGHT_UNITS / 4;