diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-27 16:28:15 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-27 16:28:15 +0100 |
commit | ae45f988bb5ea32152cca02a282d02599dbb633b (patch) | |
tree | f5349c3acda34ca9e5f7fcf9ed96fb80edee651a /client/src | |
parent | 4635f59d7c3fea4b97029f10886c62fdf38b2084 (diff) | |
download | PeerTube-ae45f988bb5ea32152cca02a282d02599dbb633b.tar.gz PeerTube-ae45f988bb5ea32152cca02a282d02599dbb633b.tar.zst PeerTube-ae45f988bb5ea32152cca02a282d02599dbb633b.zip |
Fix comment reply
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/app/videos/+video-watch/comment/video-comment.component.ts | 40 |
1 files changed, 14 insertions, 26 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 index b8e2acd52..5af6e3335 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.component.ts | |||
@@ -1,11 +1,8 @@ | |||
1 | import { Component, EventEmitter, Input, Output } from '@angular/core' | 1 | import { Component, EventEmitter, Input, Output } from '@angular/core' |
2 | import { NotificationsService } from 'angular2-notifications' | ||
3 | import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' | 2 | import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' |
4 | import { AuthService } from '../../../core/auth' | 3 | import { AuthService } from '../../../core/auth' |
5 | import { User } from '../../../shared/users' | ||
6 | import { Video } from '../../../shared/video/video.model' | 4 | import { Video } from '../../../shared/video/video.model' |
7 | import { VideoComment } from './video-comment.model' | 5 | import { VideoComment } from './video-comment.model' |
8 | import { VideoCommentService } from './video-comment.service' | ||
9 | 6 | ||
10 | @Component({ | 7 | @Component({ |
11 | selector: 'my-video-comment', | 8 | selector: 'my-video-comment', |
@@ -21,31 +18,22 @@ export class VideoCommentComponent { | |||
21 | @Output() wantedToReply = new EventEmitter<VideoComment>() | 18 | @Output() wantedToReply = new EventEmitter<VideoComment>() |
22 | @Output() resetReply = new EventEmitter() | 19 | @Output() resetReply = new EventEmitter() |
23 | 20 | ||
24 | constructor (private authService: AuthService, | 21 | constructor (private authService: AuthService) { |
25 | private notificationsService: NotificationsService, | ||
26 | private videoCommentService: VideoCommentService) { | ||
27 | } | 22 | } |
28 | 23 | ||
29 | onCommentReplyCreated (comment: VideoComment) { | 24 | onCommentReplyCreated (createdComment: VideoComment) { |
30 | this.videoCommentService.addCommentReply(this.video.id, this.comment.id, comment) | 25 | if (!this.commentTree) { |
31 | .subscribe( | 26 | this.commentTree = { |
32 | createdComment => { | 27 | comment: this.comment, |
33 | if (!this.commentTree) { | 28 | children: [] |
34 | this.commentTree = { | 29 | } |
35 | comment: this.comment, | 30 | } |
36 | children: [] | 31 | |
37 | } | 32 | this.commentTree.children.push({ |
38 | } | 33 | comment: createdComment, |
39 | 34 | children: [] | |
40 | this.commentTree.children.push({ | 35 | }) |
41 | comment: createdComment, | 36 | this.resetReply.emit() |
42 | children: [] | ||
43 | }) | ||
44 | this.resetReply.emit() | ||
45 | }, | ||
46 | |||
47 | err => this.notificationsService.error('Error', err.message) | ||
48 | ) | ||
49 | } | 37 | } |
50 | 38 | ||
51 | onWantToReply () { | 39 | onWantToReply () { |