From 66309813d5aef7a413dbcb8fda4d2b4f18c0ed1c Mon Sep 17 00:00:00 2001 From: softsimon Date: Fri, 29 Mar 2024 16:30:55 +0900 Subject: [PATCH] Changing to async pipe --- .../blockchain-blocks.component.html | 6 ++++-- .../blockchain-blocks/blockchain-blocks.component.ts | 11 +++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html index 2224ec0bf..ac29524bb 100644 --- a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html +++ b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html @@ -40,12 +40,14 @@ -
-
+
+
diff --git a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts index e81e97acc..02591f657 100644 --- a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts +++ b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, OnDestroy, ChangeDetectionStrategy, ChangeDetectorRef, Input, OnChanges, SimpleChanges } from '@angular/core'; -import { Observable, Subscription } from 'rxjs'; +import { BehaviorSubject, Observable, Subscription } from 'rxjs'; import { StateService } from '../../services/state.service'; import { specialBlocks } from '../../app.constants'; import { BlockExtended } from '../../interfaces/node-api.interface'; @@ -45,6 +45,7 @@ export class BlockchainBlocksComponent implements OnInit, OnChanges, OnDestroy { markBlockSubscription: Subscription; txConfirmedSubscription: Subscription; loadingBlocks$: Observable; + showMiningInfo$: BehaviorSubject = new BehaviorSubject(false); blockStyles = []; emptyBlockStyles = []; interval: any; @@ -54,8 +55,6 @@ export class BlockchainBlocksComponent implements OnInit, OnChanges, OnDestroy { arrowLeftPx = 30; blocksFilled = false; arrowTransition = '1s'; - showMiningInfo = false; - showMiningInfoSubscription: Subscription; timeLtrSubscription: Subscription; timeLtr: boolean; @@ -94,10 +93,7 @@ export class BlockchainBlocksComponent implements OnInit, OnChanges, OnDestroy { if (['', 'testnet', 'signet'].includes(this.stateService.network)) { this.enabledMiningInfoIfNeeded(this.location.path()); this.location.onUrlChange((url) => this.enabledMiningInfoIfNeeded(url)); - this.showMiningInfoSubscription = this.stateService.showMiningInfo$.subscribe((showMiningInfo) => { - this.showMiningInfo = showMiningInfo; - this.cd.markForCheck(); - }); + this.showMiningInfo$ = this.stateService.showMiningInfo$; } this.timeLtrSubscription = this.stateService.timeLtr.subscribe((ltr) => { @@ -210,7 +206,6 @@ export class BlockchainBlocksComponent implements OnInit, OnChanges, OnDestroy { this.tabHiddenSubscription.unsubscribe(); this.markBlockSubscription.unsubscribe(); this.timeLtrSubscription.unsubscribe(); - this.showMiningInfoSubscription.unsubscribe(); clearInterval(this.interval); }