Bartosz Dziewoński has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/133895

Change subject: mediawiki.page.watch.ajax: Disable watch link while waiting for 
API response
......................................................................

mediawiki.page.watch.ajax: Disable watch link while waiting for API response

Previously clicking the watch link several times in a row would fire
several requests to the API, and the final result would depend on the
order in which they arrived. Let's not allow that.

This also removes the special-case for the 'loading' class, it is now
always added or removed.

Bug: 65434
Change-Id: Ib91ec8505d04945dc77e48ab70b5c94e3da47d9c
---
M resources/src/mediawiki.page/mediawiki.page.watch.ajax.js
1 file changed, 8 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/95/133895/1

diff --git a/resources/src/mediawiki.page/mediawiki.page.watch.ajax.js 
b/resources/src/mediawiki.page/mediawiki.page.watch.ajax.js
index 3b0aeee..15e9aba 100644
--- a/resources/src/mediawiki.page/mediawiki.page.watch.ajax.js
+++ b/resources/src/mediawiki.page/mediawiki.page.watch.ajax.js
@@ -57,13 +57,10 @@
                        $li.prop( 'id', 'ca-' + action );
                }
 
-               // Special case for vector icon
-               if ( $li.hasClass( 'icon' ) ) {
-                       if ( state === 'loading' ) {
-                               $link.addClass( 'loading' );
-                       } else {
-                               $link.removeClass( 'loading' );
-                       }
+               if ( state === 'loading' ) {
+                       $link.addClass( 'loading' );
+               } else {
+                       $link.removeClass( 'loading' );
                }
        }
 
@@ -133,6 +130,10 @@
 
                        $link = $( this );
 
+                       if ( $link.hasClass( 'loading' ) ) {
+                               return;
+                       }
+
                        updateWatchLink( $link, action, 'loading' );
 
                        api = new mw.Api();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib91ec8505d04945dc77e48ab70b5c94e3da47d9c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>

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

Reply via email to