<img [src]="getAvatarUrl(comment.account)" alt="Avatar" />
<div class="comment">
+ <span class="marked-comment" *ngIf="comment.marked">Marked comment</span>
<div class="comment-account-date">
<a target="_blank" [href]="comment.account.url" class="comment-account">{{ comment.by }}</a>
- <div class="comment-date">{{ comment.createdAt | myFromNow }}</div>
+ <a [routerLink]="['/videos/watch', video.uuid, 'comment', comment.id]" class="comment-date">{{ comment.createdAt | myFromNow }}</a>
</div>
<div class="comment-html" [innerHTML]="sanitizedCommentHTML"></div>
import { VideoDetails } from '../../../shared/video/video-details.model'
import { VideoComment } from './video-comment.model'
import { VideoCommentService } from './video-comment.service'
+import { ActivatedRoute } from '@angular/router'
@Component({
selector: 'my-video-comments',
inReplyToCommentId: number
threadComments: { [ id: number ]: VideoCommentThreadTree } = {}
threadLoading: { [ id: number ]: boolean } = {}
+ markedCommentID: number
constructor (
private authService: AuthService,
private notificationsService: NotificationsService,
private confirmService: ConfirmService,
- private videoCommentService: VideoCommentService
+ private videoCommentService: VideoCommentService,
+ private activatedRoute: ActivatedRoute
) {}
ngOnChanges (changes: SimpleChanges) {
res => {
this.comments = this.comments.concat(res.comments)
this.componentPagination.totalItems = res.totalComments
+
+ if (this.markedCommentID) {
+ // If there is a marked comment, retrieve it separately as it may not be on this page, filter to prevent duplicate
+ this.comments = this.comments.filter(value => value.id !== this.markedCommentID)
+ this.videoCommentService.getVideoThreadComments(this.video.id, this.markedCommentID).subscribe(
+ res => {
+ let comment = new VideoComment(res.comment)
+ comment.marked = true
+ this.comments.unshift(comment) // Insert marked comment at the beginning
+ }
+ )
+ }
},
err => this.notificationsService.error('Error', err.message)
this.componentPagination.currentPage = 1
this.componentPagination.totalItems = null
+ // Find marked comment in params
+ this.activatedRoute.params.subscribe(
+ params => {
+ if (params['commentId']) {
+ this.markedCommentID = +params['commentId']
+ }
+ }
+ )
+
this.loadMoreComments()
}
}