import { Component , OnDestroy , OnInit } from '@angular/core' ; import { Subscription } from 'rxjs' ; import { CompassService } from '../../compass/compass.service' ; import { DiscoveryTag , DiscoveryTagsService , } from '../../discovery/tags/tags.service' ; import { TagSettingsService } from '../../tag-settings/tag-settings.service' ; import { ContentSettingsTab , ContentSettingsService , } from '../content-settings.service' ; const noOp = ( ) => { } ; @ Component ( { selector : 'm-contentSettings' , templateUrl : './content-settings.component.html' , styleUrls : [ './content-settings.component.ng.scss' ] , } ) export class ContentSettingsComponent implements OnInit , OnDestroy { activeTab : ContentSettingsTab ; private subscriptions : Subscription [ ] = [ ] ; onSaveIntent : ( ) => void = noOp ; constructor ( public service , protected compassService , protected tagSettingsService , protected discoveryTagsService ) { } ngOnInit ( ) { this . subscriptions . push ( this . service . activeTab$ . subscribe ( tab => { this . activeTab = tab ; } ) ) ; } ngOnDestroy ( ) { for ( const subscription of this . subscriptions ) { subscription . unsubscribe ( ) ; } } submit ( ) { switch ( this . activeTab ) { case 'tags' : this . tagSettingsService . submitRequested$ . next ( true ) ; break ; case 'compass' : this . compassService . submitRequested$ . next ( true ) ; } } }