]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/videos/+video-watch/comment/video-comment.component.ts
Merge branch 'release/v1.2.0'
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-watch / comment / video-comment.component.ts
index 7c664ca603c1770bd18d8d2c0e0365ec21633f8b..aba7f9d1c2cb9f87144b5be7d6193a9add8407f2 100644 (file)
@@ -1,12 +1,10 @@
 import { Component, EventEmitter, Input, OnChanges, 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'
 import { AuthService } from '../../../core/auth'
-import { Account } from '../../../shared/account/account.model'
 import { Video } from '../../../shared/video/video.model'
 import { VideoComment } from './video-comment.model'
+import { HtmlRendererService } from '@app/shared/renderer'
 
 @Component({
   selector: 'my-video-comment',
@@ -27,9 +25,12 @@ export class VideoCommentComponent implements OnInit, OnChanges {
   @Output() resetReply = new EventEmitter()
 
   sanitizedCommentHTML = ''
-  newParentComments = []
+  newParentComments: VideoComment[] = []
 
-  constructor (private authService: AuthService) {}
+  constructor (
+    private htmlRenderer: HtmlRendererService,
+    private authService: AuthService
+  ) {}
 
   get user () {
     return this.authService.getUser()
@@ -53,7 +54,7 @@ export class VideoCommentComponent implements OnInit, OnChanges {
       this.threadCreated.emit(this.commentTree)
     }
 
-    this.commentTree.children.push({
+    this.commentTree.children.unshift({
       comment: createdComment,
       children: []
     })
@@ -76,10 +77,6 @@ export class VideoCommentComponent implements OnInit, OnChanges {
     this.resetReply.emit()
   }
 
-  getAvatarUrl (account: AccountInterface) {
-    return Account.GET_ACCOUNT_AVATAR_URL(account)
-  }
-
   isRemovableByUser () {
     return this.isUserLoggedIn() &&
       (
@@ -89,9 +86,7 @@ export class VideoCommentComponent implements OnInit, OnChanges {
   }
 
   private init () {
-    this.sanitizedCommentHTML = sanitizeHtml(this.comment.text, {
-      allowedTags: [ 'p', 'span' ]
-    })
+    this.sanitizedCommentHTML = this.htmlRenderer.toSafeHtml(this.comment.text)
 
     this.newParentComments = this.parentComments.concat([ this.comment ])
   }