X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fshared-moderation%2Fuser-ban-modal.component.ts;h=a03bd728674a6c52296c188e843c2c700e74d56b;hb=256fb92e67a52a81ebe46ea6f5d4094987cebca7;hp=f9a0381c5b0383db1aeeb8df0288fb23ff2c5e70;hpb=66357162f8e1227495f09bd4f68446aad7071c6d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/shared-moderation/user-ban-modal.component.ts b/client/src/app/shared/shared-moderation/user-ban-modal.component.ts index f9a0381c5..a03bd7286 100644 --- a/client/src/app/shared/shared-moderation/user-ban-modal.component.ts +++ b/client/src/app/shared/shared-moderation/user-ban-modal.component.ts @@ -1,9 +1,10 @@ import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' import { Notifier, UserService } from '@app/core' -import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' +import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' import { User } from '@shared/models' +import { USER_BAN_REASON_VALIDATOR } from '../form-validators/user-validators' @Component({ selector: 'my-user-ban-modal', @@ -21,15 +22,14 @@ export class UserBanModalComponent extends FormReactive implements OnInit { protected formValidatorService: FormValidatorService, private modalService: NgbModal, private notifier: Notifier, - private userService: UserService, - private userValidatorsService: UserValidatorsService + private userService: UserService ) { super() } ngOnInit () { this.buildForm({ - reason: this.userValidatorsService.USER_BAN_REASON + reason: USER_BAN_REASON_VALIDATOR }) } @@ -43,12 +43,12 @@ export class UserBanModalComponent extends FormReactive implements OnInit { this.openedModal.close() } - async banUser () { + banUser () { const reason = this.form.value['reason'] || undefined this.userService.banUsers(this.usersToBan, reason) - .subscribe( - () => { + .subscribe({ + next: () => { const message = Array.isArray(this.usersToBan) ? $localize`${this.usersToBan.length} users banned.` : $localize`User ${this.usersToBan.username} banned.` @@ -59,8 +59,8 @@ export class UserBanModalComponent extends FormReactive implements OnInit { this.hide() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } }