diff options
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/app/videos/+video-watch/comment/video-comment-add.component.ts | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts index 46d7a4e9e..9998685e8 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts | |||
@@ -27,6 +27,8 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { | |||
27 | 27 | ||
28 | @ViewChild('textarea') private textareaElement: ElementRef | 28 | @ViewChild('textarea') private textareaElement: ElementRef |
29 | 29 | ||
30 | private addingComment = false | ||
31 | |||
30 | constructor ( | 32 | constructor ( |
31 | protected formValidatorService: FormValidatorService, | 33 | protected formValidatorService: FormValidatorService, |
32 | private videoCommentValidatorsService: VideoCommentValidatorsService, | 34 | private videoCommentValidatorsService: VideoCommentValidatorsService, |
@@ -66,6 +68,11 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { | |||
66 | } | 68 | } |
67 | 69 | ||
68 | formValidated () { | 70 | formValidated () { |
71 | // If we validate very quickly the comment form, we might comment twice | ||
72 | if (this.addingComment) return | ||
73 | |||
74 | this.addingComment = true | ||
75 | |||
69 | const commentCreate: VideoCommentCreate = this.form.value | 76 | const commentCreate: VideoCommentCreate = this.form.value |
70 | let obs: Observable<any> | 77 | let obs: Observable<any> |
71 | 78 | ||
@@ -77,11 +84,16 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { | |||
77 | 84 | ||
78 | obs.subscribe( | 85 | obs.subscribe( |
79 | comment => { | 86 | comment => { |
87 | this.addingComment = false | ||
80 | this.commentCreated.emit(comment) | 88 | this.commentCreated.emit(comment) |
81 | this.form.reset() | 89 | this.form.reset() |
82 | }, | 90 | }, |
83 | 91 | ||
84 | err => this.notificationsService.error(this.i18n('Error'), err.text) | 92 | err => { |
93 | this.addingComment = false | ||
94 | |||
95 | this.notificationsService.error(this.i18n('Error'), err.text) | ||
96 | } | ||
85 | ) | 97 | ) |
86 | } | 98 | } |
87 | 99 | ||