-import { Component, EventEmitter, Input, Output } from '@angular/core'
+import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
+import * as sanitizeHtml from 'sanitize-html'
import { Account as AccountInterface } from '../../../../../../shared/models/actors'
import { UserRight } from '../../../../../../shared/models/users'
import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model'
templateUrl: './video-comment.component.html',
styleUrls: ['./video-comment.component.scss']
})
-export class VideoCommentComponent {
+export class VideoCommentComponent implements OnInit {
@Input() video: Video
@Input() comment: VideoComment
+ @Input() parentComments: VideoComment[] = []
@Input() commentTree: VideoCommentThreadTree
@Input() inReplyToCommentId: number
@Output() threadCreated = new EventEmitter<VideoCommentThreadTree>()
@Output() resetReply = new EventEmitter()
+ sanitizedCommentHTML = ''
+ newParentComments = []
+
constructor (private authService: AuthService) {}
get user () {
return this.authService.getUser()
}
+ ngOnInit () {
+ this.sanitizedCommentHTML = sanitizeHtml(this.comment.text, {
+ allowedTags: [ 'p', 'span' ]
+ })
+
+ this.newParentComments = this.parentComments.concat([ this.comment ])
+ }
+
onCommentReplyCreated (createdComment: VideoComment) {
if (!this.commentTree) {
this.commentTree = {