Arrow bugfix: Unsubscribe all the observables when leaving view.
This commit is contained in:
parent
04f1879fd1
commit
58178f4563
@ -27,7 +27,6 @@ export class BlockComponent implements OnInit, OnDestroy {
|
|||||||
isLoadingTransactions = true;
|
isLoadingTransactions = true;
|
||||||
error: any;
|
error: any;
|
||||||
blockSubsidy: number;
|
blockSubsidy: number;
|
||||||
subscription: Subscription;
|
|
||||||
fees: number;
|
fees: number;
|
||||||
paginationMaxSize: number;
|
paginationMaxSize: number;
|
||||||
coinbaseTx: Transaction;
|
coinbaseTx: Transaction;
|
||||||
@ -38,6 +37,12 @@ export class BlockComponent implements OnInit, OnDestroy {
|
|||||||
showPreviousBlocklink = true;
|
showPreviousBlocklink = true;
|
||||||
showNextBlocklink = true;
|
showNextBlocklink = true;
|
||||||
|
|
||||||
|
subscription: Subscription;
|
||||||
|
keyNavigationSubscription: Subscription;
|
||||||
|
blocksSubscription: Subscription;
|
||||||
|
networkChangedSubscription: Subscription;
|
||||||
|
queryParamsSubscription: Subscription;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private location: Location,
|
private location: Location,
|
||||||
@ -154,7 +159,7 @@ export class BlockComponent implements OnInit, OnDestroy {
|
|||||||
this.isLoadingBlock = false;
|
this.isLoadingBlock = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.stateService.blocks$
|
this.blocksSubscription = this.stateService.blocks$
|
||||||
.subscribe(([block]) => {
|
.subscribe(([block]) => {
|
||||||
this.latestBlock = block;
|
this.latestBlock = block;
|
||||||
this.latestBlocks.unshift(block);
|
this.latestBlocks.unshift(block);
|
||||||
@ -162,10 +167,10 @@ export class BlockComponent implements OnInit, OnDestroy {
|
|||||||
this.setNextAndPreviousBlockLink();
|
this.setNextAndPreviousBlockLink();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.stateService.networkChanged$
|
this.networkChangedSubscription = this.stateService.networkChanged$
|
||||||
.subscribe((network) => this.network = network);
|
.subscribe((network) => this.network = network);
|
||||||
|
|
||||||
this.route.queryParams.subscribe((params) => {
|
this.queryParamsSubscription = this.route.queryParams.subscribe((params) => {
|
||||||
if (params.showDetails === 'true') {
|
if (params.showDetails === 'true') {
|
||||||
this.showDetails = true;
|
this.showDetails = true;
|
||||||
} else {
|
} else {
|
||||||
@ -173,7 +178,7 @@ export class BlockComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.stateService.keyNavigation$.subscribe((event) => {
|
this.keyNavigationSubscription = this.stateService.keyNavigation$.subscribe((event) => {
|
||||||
if (this.showPreviousBlocklink && event.key === 'ArrowRight' && this.nextBlockHeight - 2 >= 0) {
|
if (this.showPreviousBlocklink && event.key === 'ArrowRight' && this.nextBlockHeight - 2 >= 0) {
|
||||||
this.navigateToPreviousBlock();
|
this.navigateToPreviousBlock();
|
||||||
}
|
}
|
||||||
@ -186,6 +191,10 @@ export class BlockComponent implements OnInit, OnDestroy {
|
|||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.stateService.markBlock$.next({});
|
this.stateService.markBlock$.next({});
|
||||||
this.subscription.unsubscribe();
|
this.subscription.unsubscribe();
|
||||||
|
this.keyNavigationSubscription.unsubscribe();
|
||||||
|
this.blocksSubscription.unsubscribe();
|
||||||
|
this.networkChangedSubscription.unsubscribe();
|
||||||
|
this.queryParamsSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
setBlockSubsidy() {
|
setBlockSubsidy() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user