X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fvideos%2F%2Bvideo-watch%2Fcomment%2Fvideo-comments.component.ts;h=6025256deccfbc8505858f3c812855a0d13a8363;hb=339632b4a3f94a6ebee3767054ef6c701858a785;hp=030dee9af05fc5e9afa503916fb3de22ef9a588b;hpb=4cb6d4578893db310297d7e118ce2fb7ecb952a3;p=github%2FChocobozzz%2FPeerTube.git 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 @@ -import { Component, Input, OnInit } from '@angular/core' +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core' import { ConfirmService } from '@app/core' import { NotificationsService } from 'angular2-notifications' import { VideoComment as VideoCommentInterface, VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' @@ -15,7 +15,7 @@ import { VideoCommentService } from './video-comment.service' templateUrl: './video-comments.component.html', styleUrls: ['./video-comments.component.scss'] }) -export class VideoCommentsComponent implements OnInit { +export class VideoCommentsComponent implements OnChanges { @Input() video: VideoDetails @Input() user: User @@ -37,9 +37,9 @@ export class VideoCommentsComponent implements OnInit { private videoCommentService: VideoCommentService ) {} - ngOnInit () { - if (this.video.commentsEnabled === true) { - this.loadMoreComments() + ngOnChanges (changes: SimpleChanges) { + if (changes['video']) { + this.loadVideoComments() } } @@ -152,4 +152,21 @@ export class VideoCommentsComponent implements OnInit { this.deleteLocalCommentThread(commentChild, commentToDelete) } } + + private loadVideoComments () { + if (this.video.commentsEnabled === true) { + // Reset all our fields + this.comments = [] + this.threadComments = {} + this.threadLoading = {} + this.inReplyToCommentId = undefined + this.componentPagination = { + currentPage: 1, + itemsPerPage: 10, + totalItems: null + } + + this.loadMoreComments() + } + } }