import { Component , OnDestroy , OnInit } from '@angular/core' ; import { BlockExplorerService } from "@shared/services/block-explorer-service" ; import { GlobalService } from "@shared/services/global.service" ; import { Subscription } from "rxjs" ; import { SnackbarService } from "ngx-snackbar" ; @ Component ( { selector : 'app-block-explorer' , templateUrl : './block-explorer.component.html' , styleUrls : [ './block-explorer.component.scss' ] } ) export class BlockExplorerComponent implements OnInit , OnDestroy { public loading : boolean ; private subscriptions : Subscription [ ] = [ ] ; constructor ( private snackBarService , public globalService , public blockExplorerService ) { window . addEventListener ( "scroll" , ( ) => this . detectLoading ( ) ) ; this . subscriptions . push ( this . blockExplorerService . loading . subscribe ( loading => { this . loading = loading ; this . detectLoading ( ) ; } ) ) ; } private detectLoading ( ) { if ( ( window . innerHeight + window . pageYOffset ) >= document . body . offsetHeight ) { if ( this . loading ) { this . snackBarService . add ( { msg : "" , customClass : "loading-snack-bar" , action : { text : null } } ) ; } else { this . snackBarService . clear ( ) ; } } } ngOnInit ( ) { } openTransactionDetailDialog ( _transaction ) { } public onScroll ( ) { } public ngOnDestroy ( ) { window . removeEventListener ( "scroll" , ( ) => this . detectLoading ( ) ) ; this . subscriptions . forEach ( subscription => subscription . unsubscribe ( ) ) ; } }