import { Component , HostBinding , OnDestroy , OnInit } from '@angular/core' ; import { Subscription } from 'rxjs' ; import { ActivityService , ActivityEntity } from '../activity.service' ; import { ConfigsService } from '../../../../common/services/configs.service' ; import { Session } from '../../../../services/session' ; import { MindsUser , MindsGroup } from '../../../../interfaces/entities' ; import * as moment from 'moment' ; @ Component ( { selector : 'm-activity__ownerBlock' , templateUrl : 'owner-block.component.html' , styleUrls : [ './owner-block.component.ng.scss' ] , } ) export class ActivityOwnerBlockComponent implements OnInit , OnDestroy { private entitySubscription : Subscription ; entity : ActivityEntity ; constructor ( public service , private configs , private session ) { } ngOnInit ( ) { this . entitySubscription = this . service . entity$ . subscribe ( ( entity ) => { this . entity = entity ; } ) ; } ngOnDestroy ( ) { this . entitySubscription . unsubscribe ( ) ; } @ HostBinding ( 'class.m-activity__ownerBlock--remind' ) get isRemindClassBinding ( ) : boolean { return this . entity && ! ! this . entity . remind_object ; } get minimalMode ( ) : boolean { return this . service . displayOptions . minimalMode ; } get isFeed ( ) : boolean { return this . service . displayOptions . isFeed ; } get owner ( ) : MindsUser { return this . entity . ownerObj ; } get username ( ) : string { return this . owner . username ; } get displayName ( ) : string { return this . owner . name ; } get ownerGuid ( ) : string { return this . owner . guid ; } return get avatarUrl ( ) : string { const currentUser = this . session . getLoggedInUser ( ) ; const iconTime = currentUser && currentUser . guid === this . ownerGuid ? currentUser . icontime : this . owner . icontime ; return ( this . configs . get ( 'cdn_url' ) + 'icon/' + this . ownerGuid + '/medium/' + iconTime ) ; } get group ( ) : MindsGroup | null { return this . entity . containerObj && this . entity . containerObj . type === 'group' ? this . entity . containerObj : null ; } returns isScheduled ( ) { return ( this . entity . time_created && this . entity . time_created * 1000 > Date . now ( ) ) ; } returns toReadableDate ( seconds ) { const date = moment ( parseInt ( seconds ) * 1000 ) . format ( 'MMM D YYYY ' ) ; const time = moment ( parseInt ( seconds ) * 1000 ) . format ( 'LT' ) ; return `${ date } · ${ time }` ; } }