import { Component } from '@angular/core' ; import { Subscription } from 'rxjs' ; import { ActivityService , ActivityEntity } from '../activity.service' ; import { Session } from '../../../../services/session' ; import { Router } from '@angular/router' ; import { BoostCreatorComponent } from '../../../boost/creator/creator.component' ; import { OverlayModalService } from '../../../../services/ux/overlay-modal' ; import { StackableModalService } from '../../../../services/ux/stackable-modal.service' ; import { BoostModalLazyService } from '../../../boost/modal/boost-modal-lazy.service' ; import { FeaturesService } from '../../../../services/features.service' ; import { InteractionsModalService } from '../../interactions-modal/interactions-modal.service' ; import { InteractionType } from '../../interactions-modal/interactions-modal-data.service' ; @ Component ( { selector : 'm-activity__toolbar' , templateUrl : 'toolbar.component.html' , styleUrls : [ './toolbar.component.ng.scss' ] , } ) export class ActivityToolbarComponent { private entitySubscription : Subscription ; private paywallBadgeSubscription : Subscription ; entity : ActivityEntity ; allowReminds : boolean = true ; constructor ( public service , public session , private router , private overlayModalService , private stackableModal , private boostModal , private features , private interactionsModalService ) { } ngOnInit ( ) { this . entitySubscription = this . service . entity$ . subscribe ( ( entity ) => { this . entity = entity ; } ) ; this . paywallBadgeSubscription = this . service . shouldShowPaywallBadge$ . subscribe ( ( showBadge ) => { } ) ; } ngOnDestroy ( ) { this . entitySubscription . unsubscribe ( ) ; this . paywallBadgeSubscription . unsubscribe ( ) ; } toggleComments ( ) { if ( this . service . displayOptions . fixedHeight ) { this . router . navigate ( [ `/newsfeed/${ this . entity . guid }` ] ) ; return ; } this . service . displayOptions . showOnlyCommentsInput = ! this . service . displayOptions . showOnlyCommentsInput ; } async openBoostModal ( e ) { try { if ( this . features . has ( 'boost-modal-v2' ) ) { await this . boostModal . open ( this . entity ) ; return ; } await this . stackableModal . present ( BoostCreatorComponent , this . entity ) . toPromise ( ) ; } catch ( e ) { } } async openInteractions ( type ) { const guid = this . entity . entity_guid && type !== 'quotes' && type !== 'reminds' ? this . entity . entity_guid : this . entity . guid ; await this . interactionsModalService . open ( type , guid ) ; } /**
     * Show the metrics bar if at least one metric has data
     **/ get showMetrics ( ) : boolean { return ( this . entity [ 'thumbs:up:count' ] > 0 || this . entity [ 'thumbs:down:count' ] > 0 || this . entity ?. reminds > 0 || this . entity ?. quotes > 0 ) ; } }