1 import { Component, EventEmitter, Input, Output } from '@angular/core'
2 import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model'
3 import { AuthService } from '../../../core/auth'
4 import { Video } from '../../../shared/video/video.model'
5 import { VideoComment } from './video-comment.model'
8 selector: 'my-video-comment',
9 templateUrl: './video-comment.component.html',
10 styleUrls: ['./video-comment.component.scss']
12 export class VideoCommentComponent {
14 @Input() comment: VideoComment
15 @Input() commentTree: VideoCommentThreadTree
16 @Input() inReplyToCommentId: number
18 @Output() wantedToReply = new EventEmitter<VideoComment>()
19 @Output() resetReply = new EventEmitter()
21 constructor (private authService: AuthService) {
24 onCommentReplyCreated (createdComment: VideoComment) {
25 if (!this.commentTree) {
27 comment: this.comment,
32 this.commentTree.children.push({
33 comment: createdComment,
36 this.resetReply.emit()
40 this.wantedToReply.emit(this.comment)
44 return this.authService.isLoggedIn()
47 // Event from child comment
48 onWantedToReply (comment: VideoComment) {
49 this.wantedToReply.emit(comment)
53 this.resetReply.emit()