]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-moderation/report-modals/account-report.component.ts
Fix report modal error
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-moderation / report-modals / account-report.component.ts
index cc8875f7742c27635c05b0c3cbd6d3e797a7b1e6..78c9b338292f6c0d20e18f541e0d0b1ae5adce8c 100644 (file)
@@ -1,5 +1,5 @@
 import { mapValues, pickBy } from 'lodash-es'
-import { Component, Input, OnInit, ViewChild } from '@angular/core'
+import { Component, OnInit, ViewChild } from '@angular/core'
 import { Notifier } from '@app/core'
 import { ABUSE_REASON_VALIDATOR } from '@app/shared/form-validators/abuse-validators'
 import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
@@ -16,13 +16,12 @@ import { AbuseService } from '../abuse.service'
   styleUrls: [ './report.component.scss' ]
 })
 export class AccountReportComponent extends FormReactive implements OnInit {
-  @Input() account: Account = null
-
   @ViewChild('modal', { static: true }) modal: NgbModal
 
   error: string = null
   predefinedReasons: { id: AbusePredefinedReasonsString, label: string, description?: string, help?: string }[] = []
   modalTitle: string
+  account: Account = null
 
   private openedModal: NgbModalRef
 
@@ -48,8 +47,6 @@ export class AccountReportComponent extends FormReactive implements OnInit {
   }
 
   ngOnInit () {
-    this.modalTitle = $localize`Report ${this.account.displayName}`
-
     this.buildForm({
       reason: ABUSE_REASON_VALIDATOR,
       predefinedReasons: mapValues(abusePredefinedReasonsMap, r => null)
@@ -58,7 +55,11 @@ export class AccountReportComponent extends FormReactive implements OnInit {
     this.predefinedReasons = this.abuseService.getPrefefinedReasons('account')
   }
 
-  show () {
+  show (account: Account) {
+    this.account = account
+
+    this.modalTitle = $localize`Report ${this.account.displayName}`
+
     this.openedModal = this.modalService.open(this.modal, { centered: true, keyboard: false, size: 'lg' })
   }
 
@@ -77,14 +78,14 @@ export class AccountReportComponent extends FormReactive implements OnInit {
       account: {
         id: this.account.id
       }
-    }).subscribe(
-      () => {
+    }).subscribe({
+      next: () => {
         this.notifier.success($localize`Account reported.`)
         this.hide()
       },
 
-      err => this.notifier.error(err.message)
-    )
+      error: err => this.notifier.error(err.message)
+    })
   }
 
   isRemote () {