aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-watch/comment/video-comment.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-27 16:11:53 +0100
committerChocobozzz <me@florianbigard.com>2017-12-27 16:11:53 +0100
commit4635f59d7c3fea4b97029f10886c62fdf38b2084 (patch)
treed97357a00042bbfb33c4177ee24c01171d28dfce /client/src/app/videos/+video-watch/comment/video-comment.component.ts
parentea44f375f5d3da06ca0aebfe871b9f924a26ec29 (diff)
downloadPeerTube-4635f59d7c3fea4b97029f10886c62fdf38b2084.tar.gz
PeerTube-4635f59d7c3fea4b97029f10886c62fdf38b2084.tar.zst
PeerTube-4635f59d7c3fea4b97029f10886c62fdf38b2084.zip
Add video comment components
Diffstat (limited to 'client/src/app/videos/+video-watch/comment/video-comment.component.ts')
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.component.ts67
1 files changed, 67 insertions, 0 deletions
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.ts b/client/src/app/videos/+video-watch/comment/video-comment.component.ts
new file mode 100644
index 000000000..b8e2acd52
--- /dev/null
+++ b/client/src/app/videos/+video-watch/comment/video-comment.component.ts
@@ -0,0 +1,67 @@
1import { Component, EventEmitter, Input, Output } from '@angular/core'
2import { NotificationsService } from 'angular2-notifications'
3import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model'
4import { AuthService } from '../../../core/auth'
5import { User } from '../../../shared/users'
6import { Video } from '../../../shared/video/video.model'
7import { VideoComment } from './video-comment.model'
8import { VideoCommentService } from './video-comment.service'
9
10@Component({
11 selector: 'my-video-comment',
12 templateUrl: './video-comment.component.html',
13 styleUrls: ['./video-comment.component.scss']
14})
15export class VideoCommentComponent {
16 @Input() video: Video
17 @Input() comment: VideoComment
18 @Input() commentTree: VideoCommentThreadTree
19 @Input() inReplyToCommentId: number
20
21 @Output() wantedToReply = new EventEmitter<VideoComment>()
22 @Output() resetReply = new EventEmitter()
23
24 constructor (private authService: AuthService,
25 private notificationsService: NotificationsService,
26 private videoCommentService: VideoCommentService) {
27 }
28
29 onCommentReplyCreated (comment: VideoComment) {
30 this.videoCommentService.addCommentReply(this.video.id, this.comment.id, comment)
31 .subscribe(
32 createdComment => {
33 if (!this.commentTree) {
34 this.commentTree = {
35 comment: this.comment,
36 children: []
37 }
38 }
39
40 this.commentTree.children.push({
41 comment: createdComment,
42 children: []
43 })
44 this.resetReply.emit()
45 },
46
47 err => this.notificationsService.error('Error', err.message)
48 )
49 }
50
51 onWantToReply () {
52 this.wantedToReply.emit(this.comment)
53 }
54
55 isUserLoggedIn () {
56 return this.authService.isLoggedIn()
57 }
58
59 // Event from child comment
60 onWantedToReply (comment: VideoComment) {
61 this.wantedToReply.emit(comment)
62 }
63
64 onResetReply () {
65 this.resetReply.emit()
66 }
67}