import { ChangeDetectionStrategy , ChangeDetectorRef , Component , ElementRef , EventEmitter , Input , Output , Renderer2 , OnInit , OnDestroy , ViewChild , } from '@angular/core' ; import { ActivatedRoute , ActivatedRouteSnapshot , Router , } from '@angular/router' ; import { Subscription } from 'rxjs' ; import { Client } from '../../../services/api/client' ; import { Session } from '../../../services/session' ; import { Upload } from '../../../services/api/upload' ; import { AttachmentService } from '../../../services/attachment' ; import { Textarea } from '../../../common/components/editors/textarea.component' ; import { SocketsService } from '../../../services/sockets' ; import { CommentsService } from '../comments.service' ; @ Component ( { selector : 'm-comments__tree' , templateUrl : 'tree.component.html' , providers : [ AttachmentService , { provide : CommentsService , useFactory : ( _route , _client ) => { return new CommentsService ( _route , _client ) ; } , deps : [ ActivatedRoute , Client ] , } , ] , changeDetection : ChangeDetectionStrategy . OnPush , } ) export class CommentsTreeComponent { entity ; guid : string = '' ; parent : any ; @ Input ( ) limit : number = 12 ; @ Output ( ) scrollToBottom : EventEmitter < boolean > = new EventEmitter ( true ) ; @ Output ( ) scrollToCurrentPosition : EventEmitter < boolean > = new EventEmitter ( true ) ; @ Input ( ) conversation : boolean = false ; @ Input ( ) scrollable : boolean = false ; @ Input ( ) readonly : boolean = false ; @ Input ( ) canEdit : boolean = false ; @ Input ( ) canDelete : boolean = false ; @ Input ( ) showOnlyPoster : boolean = false ; @ Input ( ) compact : boolean = false ; constructor ( public session , public client , public attachment , public sockets , private renderer , private cd , private router ) { } @ Input ( 'entity' ) set _entity ( value ) { this . entity = value ; this . guid = this . entity . guid ; if ( this . entity . entity_guid ) this . guid = this . entity . entity_guid ; this . parent = this . entity ; if ( ! this . canDelete ) { this . canDelete = this . entity . owner_guid == this . session . getLoggedInUser ( ) . guid ; } } onScrollToBottom ( ) { this . scrollToBottom . next ( true ) ; } onScrollToCurrentPosition ( ) { this . scrollToCurrentPosition . next ( true ) ; } detectChanges ( ) { this . cd . markForCheck ( ) ; this . cd . detectChanges ( ) ; } ngOnChanges ( changes ) { } }