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