import { Component , Input , OnInit , ViewEncapsulation , OnDestroy } from '@angular/core' ; import { NavBarGroupRef , NavBarLinkRef } from '@alfresco/adf-extensions' ; import { Store } from '@ngrx/store' ; import { AppStore , getSideNavState } from '@alfresco/aca-shared/store' ; import { Subject } from 'rxjs' ; import { takeUntil , distinctUntilChanged , debounceTime } from 'rxjs/operators' ; import { AppExtensionService } from '@alfresco/aca-shared' ; @ Component ( { selector : 'app-sidenav' , templateUrl : './sidenav.component.html' , styleUrls : [ './sidenav.component.scss' ] , encapsulation : ViewEncapsulation . None , host : { class : 'app-sidenav' } } ) export class SidenavComponent implements OnInit , OnDestroy { @ Input ( ) mode : 'collapsed' | 'expanded' = 'expanded' ; groups : Array < NavBarGroupRef > = [ ] ; private onDestroy$ = new Subject < boolean > ( ) ; constructor ( private store , private extensions ) { } ngOnInit ( ) { this . store . select ( getSideNavState ) . pipe ( debounceTime ( 300 ) , distinctUntilChanged ( ) , takeUntil ( this . onDestroy$ ) ) . subscribe ( ( ) => { this . groups = this . extensions . getApplicationNavigation ( this . extensions . navbar ) ; } ) ; } trackByGroupId ( _ , obj ) { return obj . id ; } trackByLinkId ( _ , obj ) { return obj . id ; } ngOnDestroy ( ) { this . onDestroy$ . next ( true ) ; this . onDestroy$ . complete ( ) ; } }