1 import { Component, EventEmitter, Input, Output } from '@angular/core'
2 import { Account as AccountInterface } from '../../../../../../shared/models/actors'
3 import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model'
4 import { AuthService } from '../../../core/auth'
5 import { Account } from '../../../shared/account/account.model'
6 import { Video } from '../../../shared/video/video.model'
7 import { VideoComment } from './video-comment.model'
10 selector: 'my-video-comment',
11 templateUrl: './video-comment.component.html',
12 styleUrls: ['./video-comment.component.scss']
14 export class VideoCommentComponent {
16 @Input() comment: VideoComment
17 @Input() commentTree: VideoCommentThreadTree
18 @Input() inReplyToCommentId: number
20 @Output() wantedToReply = new EventEmitter<VideoComment>()
21 @Output() resetReply = new EventEmitter()
23 constructor (private authService: AuthService) {}
26 return this.authService.getUser()
29 onCommentReplyCreated (createdComment: VideoComment) {
30 if (!this.commentTree) {
32 comment: this.comment,
37 this.commentTree.children.push({
38 comment: createdComment,
41 this.resetReply.emit()
45 this.wantedToReply.emit(this.comment)
49 return this.authService.isLoggedIn()
52 // Event from child comment
53 onWantedToReply (comment: VideoComment) {
54 this.wantedToReply.emit(comment)
58 this.resetReply.emit()
61 getAvatarUrl (account: AccountInterface) {
62 return Account.GET_ACCOUNT_AVATAR_URL(account)