jenkins-bot has submitted this change and it was merged.

Change subject: ext.thanks.revthank: Prevent double clicks while API request is 
in progress
......................................................................


ext.thanks.revthank: Prevent double clicks while API request is in progress

Bug: T53303
Change-Id: Ie886a8093469904f327bba8a0b30048fc6d6b638
---
M modules/ext.thanks.revthank.js
1 file changed, 9 insertions(+), 0 deletions(-)

Approvals:
  Florianschmidtwelzow: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ext.thanks.revthank.js b/modules/ext.thanks.revthank.js
index 63f413a..3bc5069 100644
--- a/modules/ext.thanks.revthank.js
+++ b/modules/ext.thanks.revthank.js
@@ -15,6 +15,13 @@
        // $thankElement is the element to be removed on success
        function sendThanks( $thankLink, $thankElement ) {
                var source;
+
+               if ( $thankLink.data( 'clickDisabled' ) ) {
+                       // Prevent double clicks while we haven't received a 
response from API request
+                       return false;
+               }
+               $thankLink.data( 'clickDisabled', true );
+
                if ( mw.config.get( 'wgAction' ) === 'history' ) {
                        source = 'history';
                } else {
@@ -37,6 +44,8 @@
                        },
                        // Fail
                        function ( errorCode, details ) {
+                               // If error occured, enable attempting to thank 
again
+                               $thankLink.data( 'clickDisabled', false );
                                // TODO: use something besides alert for the 
error messages
                                switch ( errorCode ) {
                                        case 'invalidrevision':

-- 
To view, visit https://gerrit.wikimedia.org/r/283375
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie886a8093469904f327bba8a0b30048fc6d6b638
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Thanks
Gerrit-Branch: master
Gerrit-Owner: Glaisher <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to