@ViewChild('textarea') private textareaElement: ElementRef
+ private addingComment = false
+
constructor (
protected formValidatorService: FormValidatorService,
private videoCommentValidatorsService: VideoCommentValidatorsService,
}
formValidated () {
+ // If we validate very quickly the comment form, we might comment twice
+ if (this.addingComment) return
+
+ this.addingComment = true
+
const commentCreate: VideoCommentCreate = this.form.value
let obs: Observable<any>
obs.subscribe(
comment => {
+ this.addingComment = false
this.commentCreated.emit(comment)
this.form.reset()
},
- err => this.notificationsService.error(this.i18n('Error'), err.text)
+ err => {
+ this.addingComment = false
+
+ this.notificationsService.error(this.i18n('Error'), err.text)
+ }
)
}