]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts
Increase timeout
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / moderation / video-comment-list / video-comment-list.component.ts
index ebbbddb43652d0219c4b12ec1f9f728b12e989b9..25fe6513301329591ab2591bf9f4272012182847 100644 (file)
@@ -1,5 +1,5 @@
 import { SortMeta } from 'primeng/api'
-import { AfterViewInit, Component, OnInit } from '@angular/core'
+import { Component, OnInit } from '@angular/core'
 import { ActivatedRoute, Router } from '@angular/router'
 import { AuthService, ConfirmService, MarkdownService, Notifier, RestPagination, RestTable } from '@app/core'
 import { AdvancedInputFilter } from '@app/shared/shared-forms'
@@ -13,9 +13,7 @@ import { FeedFormat, UserRight } from '@shared/models'
   templateUrl: './video-comment-list.component.html',
   styleUrls: [ '../../../shared/shared-moderation/moderation.scss', './video-comment-list.component.scss' ]
 })
-export class VideoCommentListComponent extends RestTable implements OnInit, AfterViewInit {
-  baseRoute = '/admin/moderation/video-comments/list'
-
+export class VideoCommentListComponent extends RestTable implements OnInit {
   comments: VideoCommentAdmin[]
   totalRecords = 0
   sort: SortMeta = { field: 'createdAt', order: -1 }
@@ -46,12 +44,17 @@ export class VideoCommentListComponent extends RestTable implements OnInit, Afte
 
   inputFilters: AdvancedInputFilter[] = [
     {
-      queryParams: { 'search': 'local:true' },
-      label: $localize`Local comments`
-    },
-    {
-      queryParams: { 'search': 'local:false' },
-      label: $localize`Remote comments`
+      title: $localize`Advanced filters`,
+      children: [
+        {
+          value: 'local:true',
+          label: $localize`Local comments`
+        },
+        {
+          value: 'local:false',
+          label: $localize`Remote comments`
+        }
+      ]
     }
   ]
 
@@ -68,7 +71,7 @@ export class VideoCommentListComponent extends RestTable implements OnInit, Afte
     private videoCommentService: VideoCommentService,
     private markdownRenderer: MarkdownService,
     private bulkService: BulkService
-    ) {
+  ) {
     super()
 
     this.videoCommentActions = [
@@ -91,7 +94,6 @@ export class VideoCommentListComponent extends RestTable implements OnInit, Afte
 
   ngOnInit () {
     this.initialize()
-    this.listenToSearchChange()
 
     this.bulkCommentActions = [
       {
@@ -103,10 +105,6 @@ export class VideoCommentListComponent extends RestTable implements OnInit, Afte
     ]
   }
 
-  ngAfterViewInit () {
-    if (this.search) this.setTableFilter(this.search, false)
-  }
-
   getIdentifier () {
     return 'VideoCommentListComponent'
   }
@@ -119,50 +117,51 @@ export class VideoCommentListComponent extends RestTable implements OnInit, Afte
     return this.selectedComments.length !== 0
   }
 
-  protected loadData () {
+  protected reloadData () {
     this.videoCommentService.getAdminVideoComments({
       pagination: this.pagination,
       sort: this.sort,
       search: this.search
-    }).subscribe(
-        async resultList => {
-          this.totalRecords = resultList.total
+    }).subscribe({
+      next: async resultList => {
+        this.totalRecords = resultList.total
 
-          this.comments = []
+        this.comments = []
 
-          for (const c of resultList.data) {
-            this.comments.push(
-              new VideoCommentAdmin(c, await this.toHtml(c.text))
-            )
-          }
-        },
+        for (const c of resultList.data) {
+          this.comments.push(
+            new VideoCommentAdmin(c, await this.toHtml(c.text))
+          )
+        }
+      },
 
-        err => this.notifier.error(err.message)
-      )
+      error: err => this.notifier.error(err.message)
+    })
   }
 
-  private async removeComments (comments: VideoCommentAdmin[]) {
+  private removeComments (comments: VideoCommentAdmin[]) {
     const commentArgs = comments.map(c => ({ videoId: c.video.id, commentId: c.id }))
 
-    this.videoCommentService.deleteVideoComments(commentArgs).subscribe(
-      () => {
-        this.notifier.success($localize`${commentArgs.length} comments deleted.`)
-        this.loadData()
-      },
+    this.videoCommentService.deleteVideoComments(commentArgs)
+      .subscribe({
+        next: () => {
+          this.notifier.success($localize`${commentArgs.length} comments deleted.`)
+          this.reloadData()
+        },
 
-      err => this.notifier.error(err.message),
+        error: err => this.notifier.error(err.message),
 
-      () => this.selectedComments = []
-    )
+        complete: () => this.selectedComments = []
+      })
   }
 
   private deleteComment (comment: VideoCommentAdmin) {
     this.videoCommentService.deleteVideoComment(comment.video.id, comment.id)
-      .subscribe(
-        () => this.loadData(),
+      .subscribe({
+        next: () => this.reloadData(),
 
-        err => this.notifier.error(err.message)
-      )
+        error: err => this.notifier.error(err.message)
+      })
   }
 
   private async deleteUserComments (comment: VideoCommentAdmin) {
@@ -176,12 +175,12 @@ export class VideoCommentListComponent extends RestTable implements OnInit, Afte
     }
 
     this.bulkService.removeCommentsOf(options)
-      .subscribe(
-        () => {
+      .subscribe({
+        next: () => {
           this.notifier.success($localize`Comments of ${options.accountName} will be deleted in a few minutes`)
         },
 
-        err => this.notifier.error(err.message)
-      )
+        error: err => this.notifier.error(err.message)
+      })
   }
 }