diff options
Diffstat (limited to 'client/src/app/videos/+video-watch/comment/video-comments.component.ts')
-rw-r--r-- | client/src/app/videos/+video-watch/comment/video-comments.component.ts | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.ts b/client/src/app/videos/+video-watch/comment/video-comments.component.ts index 030dee9af..6025256de 100644 --- a/client/src/app/videos/+video-watch/comment/video-comments.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comments.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Component, Input, OnInit } from '@angular/core' | 1 | import { Component, Input, OnChanges, SimpleChanges } from '@angular/core' |
2 | import { ConfirmService } from '@app/core' | 2 | import { ConfirmService } from '@app/core' |
3 | import { NotificationsService } from 'angular2-notifications' | 3 | import { NotificationsService } from 'angular2-notifications' |
4 | import { VideoComment as VideoCommentInterface, VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' | 4 | import { VideoComment as VideoCommentInterface, VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' |
@@ -15,7 +15,7 @@ import { VideoCommentService } from './video-comment.service' | |||
15 | templateUrl: './video-comments.component.html', | 15 | templateUrl: './video-comments.component.html', |
16 | styleUrls: ['./video-comments.component.scss'] | 16 | styleUrls: ['./video-comments.component.scss'] |
17 | }) | 17 | }) |
18 | export class VideoCommentsComponent implements OnInit { | 18 | export class VideoCommentsComponent implements OnChanges { |
19 | @Input() video: VideoDetails | 19 | @Input() video: VideoDetails |
20 | @Input() user: User | 20 | @Input() user: User |
21 | 21 | ||
@@ -37,9 +37,9 @@ export class VideoCommentsComponent implements OnInit { | |||
37 | private videoCommentService: VideoCommentService | 37 | private videoCommentService: VideoCommentService |
38 | ) {} | 38 | ) {} |
39 | 39 | ||
40 | ngOnInit () { | 40 | ngOnChanges (changes: SimpleChanges) { |
41 | if (this.video.commentsEnabled === true) { | 41 | if (changes['video']) { |
42 | this.loadMoreComments() | 42 | this.loadVideoComments() |
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
@@ -152,4 +152,21 @@ export class VideoCommentsComponent implements OnInit { | |||
152 | this.deleteLocalCommentThread(commentChild, commentToDelete) | 152 | this.deleteLocalCommentThread(commentChild, commentToDelete) |
153 | } | 153 | } |
154 | } | 154 | } |
155 | |||
156 | private loadVideoComments () { | ||
157 | if (this.video.commentsEnabled === true) { | ||
158 | // Reset all our fields | ||
159 | this.comments = [] | ||
160 | this.threadComments = {} | ||
161 | this.threadLoading = {} | ||
162 | this.inReplyToCommentId = undefined | ||
163 | this.componentPagination = { | ||
164 | currentPage: 1, | ||
165 | itemsPerPage: 10, | ||
166 | totalItems: null | ||
167 | } | ||
168 | |||
169 | this.loadMoreComments() | ||
170 | } | ||
171 | } | ||
155 | } | 172 | } |