-import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
-import { AuthService, Notifier, HtmlRendererService } from '@app/core'
-import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
+import { AuthService, HtmlRendererService, Notifier } from '@app/core'
+import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
-import { I18n } from '@ngx-translate/i18n-polyfill'
+import { logger } from '@root-helpers/logger'
import { AbuseMessage, UserAbuse } from '@shared/models'
+import { ABUSE_MESSAGE_VALIDATOR } from '../form-validators/abuse-validators'
import { AbuseService } from '../shared-moderation'
@Component({
private abuse: UserAbuse
constructor (
- protected formValidatorService: FormValidatorService,
- private abuseValidatorsService: AbuseValidatorsService,
+ protected formReactiveService: FormReactiveService,
private modalService: NgbModal,
- private i18n: I18n,
private htmlRenderer: HtmlRendererService,
private auth: AuthService,
private notifier: Notifier,
ngOnInit () {
this.buildForm({
- message: this.abuseValidatorsService.ABUSE_MESSAGE
+ message: ABUSE_MESSAGE_VALIDATOR
})
}
this.sendingMessage = true
this.abuseService.addAbuseMessage(this.abuse, this.form.value['message'])
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.form.reset()
this.sendingMessage = false
this.countMessagesUpdated.emit({ abuseId: this.abuse.id, countMessages: this.abuseMessages.length + 1 })
this.loadMessages()
},
- err => {
+ error: err => {
this.sendingMessage = false
- console.error(err)
+ logger.error(err)
this.notifier.error('Sorry but you cannot send this message. Please retry later')
}
- )
+ })
}
deleteMessage (abuseMessage: AbuseMessage) {
this.abuseService.deleteAbuseMessage(this.abuse, abuseMessage)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.countMessagesUpdated.emit({ abuseId: this.abuse.id, countMessages: this.abuseMessages.length - 1 })
this.abuseMessages = this.abuseMessages.filter(m => m.id !== abuseMessage.id)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
isMessageByMe (abuseMessage: AbuseMessage) {
getPlaceholderMessage () {
if (this.isAdminView) {
- return this.i18n('Add a message to communicate with the reporter')
+ return $localize`Add a message to communicate with the reporter`
}
- return this.i18n('Add a message to communicate with the moderation team')
+ return $localize`Add a message to communicate with the moderation team`
}
private loadMessages () {
this.abuseService.listAbuseMessages(this.abuse)
- .subscribe(
- async res => {
+ .subscribe({
+ next: async res => {
this.abuseMessages = []
for (const m of res.data) {
})
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}