Lazy import some modules
[oweals/peertube.git] / client / src / app / +admin / moderation / video-abuse-list / video-abuse-list.component.ts
index 00c8716599692146b1a4a6a29466eb6c5b67279b..3aa87566809903a2c40937c79f2e31e883c8eb18 100644 (file)
@@ -19,7 +19,7 @@ import { MarkdownService } from '@app/shared/renderer'
 export class VideoAbuseListComponent extends RestTable implements OnInit {
   @ViewChild('moderationCommentModal') moderationCommentModal: ModerationCommentModalComponent
 
-  videoAbuses: VideoAbuse[] = []
+  videoAbuses: (VideoAbuse & { moderationCommentHtml?: string, reasonHtml?: string })[] = []
   totalRecords = 0
   rowsPerPage = 10
   sort: SortMeta = { field: 'createdAt', order: 1 }
@@ -110,19 +110,28 @@ export class VideoAbuseListComponent extends RestTable implements OnInit {
 
   }
 
-  toHtml (text: string) {
-    return this.markdownRenderer.textMarkdownToHTML(text)
-  }
-
   protected loadData () {
     return this.videoAbuseService.getVideoAbuses(this.pagination, this.sort)
                .subscribe(
-                 resultList => {
-                   this.videoAbuses = resultList.data
+                 async resultList => {
                    this.totalRecords = resultList.total
+
+                   this.videoAbuses = resultList.data
+
+                   for (const abuse of this.videoAbuses) {
+                     Object.assign(abuse, {
+                       reasonHtml: await this.toHtml(abuse.reason),
+                       moderationCommentHtml: await this.toHtml(abuse.moderationComment)
+                     })
+                   }
+
                  },
 
                  err => this.notifier.error(err.message)
                )
   }
+
+  private toHtml (text: string) {
+    return this.markdownRenderer.textMarkdownToHTML(text)
+  }
 }