aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-watch/comment/video-comments.component.ts
diff options
context:
space:
mode:
authorjonathanraes <jonathanraes@users.noreply.github.com>2018-02-18 09:57:26 +0100
committerChocobozzz <me@florianbigard.com>2018-02-18 09:57:26 +0100
commitd5b53822ae7e1660cebe3a35be5ce76ea73dc1b9 (patch)
tree143c59398130bf8be2e974ca20eaff980b7242d2 /client/src/app/videos/+video-watch/comment/video-comments.component.ts
parent16f16570978bc57bbe14524e6d0cc27260191bfd (diff)
downloadPeerTube-d5b53822ae7e1660cebe3a35be5ce76ea73dc1b9.tar.gz
PeerTube-d5b53822ae7e1660cebe3a35be5ce76ea73dc1b9.tar.zst
PeerTube-d5b53822ae7e1660cebe3a35be5ce76ea73dc1b9.zip
Issue #168: youtube-like marking of comments (#297)
* youtube-like marking of comments uses GET parameters to mark comments similar to youtube * place link to comment in 'comment-date' * Use a routes to highight a comment
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.ts26
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'
9import { VideoDetails } from '../../../shared/video/video-details.model' 9import { VideoDetails } from '../../../shared/video/video-details.model'
10import { VideoComment } from './video-comment.model' 10import { VideoComment } from './video-comment.model'
11import { VideoCommentService } from './video-comment.service' 11import { VideoCommentService } from './video-comment.service'
12import { 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 }