]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/+video-watch/comment/video-comment.component.ts
5af6e33353d2e0954d7740d509e721cd2d139174
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-watch / comment / video-comment.component.ts
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'
6
7 @Component({
8 selector: 'my-video-comment',
9 templateUrl: './video-comment.component.html',
10 styleUrls: ['./video-comment.component.scss']
11 })
12 export class VideoCommentComponent {
13 @Input() video: Video
14 @Input() comment: VideoComment
15 @Input() commentTree: VideoCommentThreadTree
16 @Input() inReplyToCommentId: number
17
18 @Output() wantedToReply = new EventEmitter<VideoComment>()
19 @Output() resetReply = new EventEmitter()
20
21 constructor (private authService: AuthService) {
22 }
23
24 onCommentReplyCreated (createdComment: VideoComment) {
25 if (!this.commentTree) {
26 this.commentTree = {
27 comment: this.comment,
28 children: []
29 }
30 }
31
32 this.commentTree.children.push({
33 comment: createdComment,
34 children: []
35 })
36 this.resetReply.emit()
37 }
38
39 onWantToReply () {
40 this.wantedToReply.emit(this.comment)
41 }
42
43 isUserLoggedIn () {
44 return this.authService.isLoggedIn()
45 }
46
47 // Event from child comment
48 onWantedToReply (comment: VideoComment) {
49 this.wantedToReply.emit(comment)
50 }
51
52 onResetReply () {
53 this.resetReply.emit()
54 }
55 }