aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-18 10:29:17 +0200
committerChocobozzz <me@florianbigard.com>2018-06-18 10:29:17 +0200
commitff33642709d7d6d3953ca8e6ce11fe4ba4a56593 (patch)
treed2e7e4a9df664ee354b38cbe7d6c71ef97880ec2 /client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
parente94fc29706cd8e8fd892182d4de0a3ae80a3820f (diff)
downloadPeerTube-ff33642709d7d6d3953ca8e6ce11fe4ba4a56593.tar.gz
PeerTube-ff33642709d7d6d3953ca8e6ce11fe4ba4a56593.tar.zst
PeerTube-ff33642709d7d6d3953ca8e6ce11fe4ba4a56593.zip
Prevent commenting twice
Diffstat (limited to 'client/src/app/videos/+video-watch/comment/video-comment-add.component.ts')
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment-add.component.ts14
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