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 | 26 |
1 files changed, 25 insertions, 1 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 7ca3bafb5..7970a5dcf 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 | |||
@@ -9,6 +9,7 @@ import { SortField } from '../../../shared/video/sort-field.type' | |||
9 | import { VideoDetails } from '../../../shared/video/video-details.model' | 9 | import { VideoDetails } from '../../../shared/video/video-details.model' |
10 | import { VideoComment } from './video-comment.model' | 10 | import { VideoComment } from './video-comment.model' |
11 | import { VideoCommentService } from './video-comment.service' | 11 | import { VideoCommentService } from './video-comment.service' |
12 | import { ActivatedRoute } from '@angular/router' | ||
12 | 13 | ||
13 | @Component({ | 14 | @Component({ |
14 | selector: 'my-video-comments', | 15 | selector: 'my-video-comments', |
@@ -29,12 +30,14 @@ export class VideoCommentsComponent implements OnChanges { | |||
29 | inReplyToCommentId: number | 30 | inReplyToCommentId: number |
30 | threadComments: { [ id: number ]: VideoCommentThreadTree } = {} | 31 | threadComments: { [ id: number ]: VideoCommentThreadTree } = {} |
31 | threadLoading: { [ id: number ]: boolean } = {} | 32 | threadLoading: { [ id: number ]: boolean } = {} |
33 | markedCommentID: number | ||
32 | 34 | ||
33 | constructor ( | 35 | constructor ( |
34 | private authService: AuthService, | 36 | private authService: AuthService, |
35 | private notificationsService: NotificationsService, | 37 | private notificationsService: NotificationsService, |
36 | private confirmService: ConfirmService, | 38 | private confirmService: ConfirmService, |
37 | private videoCommentService: VideoCommentService | 39 | private videoCommentService: VideoCommentService, |
40 | private activatedRoute: ActivatedRoute | ||
38 | ) {} | 41 | ) {} |
39 | 42 | ||
40 | ngOnChanges (changes: SimpleChanges) { | 43 | ngOnChanges (changes: SimpleChanges) { |
@@ -63,6 +66,18 @@ export class VideoCommentsComponent implements OnChanges { | |||
63 | res => { | 66 | res => { |
64 | this.comments = this.comments.concat(res.comments) | 67 | this.comments = this.comments.concat(res.comments) |
65 | this.componentPagination.totalItems = res.totalComments | 68 | this.componentPagination.totalItems = res.totalComments |
69 | |||
70 | if (this.markedCommentID) { | ||
71 | // If there is a marked comment, retrieve it separately as it may not be on this page, filter to prevent duplicate | ||
72 | this.comments = this.comments.filter(value => value.id !== this.markedCommentID) | ||
73 | this.videoCommentService.getVideoThreadComments(this.video.id, this.markedCommentID).subscribe( | ||
74 | res => { | ||
75 | let comment = new VideoComment(res.comment) | ||
76 | comment.marked = true | ||
77 | this.comments.unshift(comment) // Insert marked comment at the beginning | ||
78 | } | ||
79 | ) | ||
80 | } | ||
66 | }, | 81 | }, |
67 | 82 | ||
68 | err => this.notificationsService.error('Error', err.message) | 83 | err => this.notificationsService.error('Error', err.message) |
@@ -163,6 +178,15 @@ export class VideoCommentsComponent implements OnChanges { | |||
163 | this.componentPagination.currentPage = 1 | 178 | this.componentPagination.currentPage = 1 |
164 | this.componentPagination.totalItems = null | 179 | this.componentPagination.totalItems = null |
165 | 180 | ||
181 | // Find marked comment in params | ||
182 | this.activatedRoute.params.subscribe( | ||
183 | params => { | ||
184 | if (params['commentId']) { | ||
185 | this.markedCommentID = +params['commentId'] | ||
186 | } | ||
187 | } | ||
188 | ) | ||
189 | |||
166 | this.loadMoreComments() | 190 | this.loadMoreComments() |
167 | } | 191 | } |
168 | } | 192 | } |