r110966 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110965‎ | r110966 | r110967 >
Date:21:26, 8 February 2012
Author:gregchiasson
Status:ok
Tags:aft, nodeploy 
Comment:
AFT5: noticed an issue where there was actually a legitimate reason for multiple ajax requests to be going through at the same time, so allow that when required.
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
@@ -53,7 +53,8 @@
5454 limit: 25,
5555 continue: null,
5656 continueId: null, // Sort of a tie-breaker for continue values.
57 - disabled: false // Prevent (or at least limit) a flood of ajax requests.
 57+ disabled: false, // Prevent (at least limit) a flood of ajax requests.
 58+ allowMultiple: false
5859 };
5960
6061 /**
@@ -175,11 +176,17 @@
176177 if ( activity[value] ) {
177178 $.articleFeedbackv5special.flagFeedback( id, value, -1 );
178179 } else if ( 'helpful' == value && activity.unhelpful ) {
 180+ // Allow multiple simultaneous ajax requests in this case.
 181+ $.articleFeedbackv5special.listControls.allowMultiple = true;
179182 $.articleFeedbackv5special.flagFeedback( id, 'unhelpful', -1 );
180183 $.articleFeedbackv5special.flagFeedback( id, 'helpful', 1 );
 184+ $.articleFeedbackv5special.listControls.allowMultiple = false;
181185 } else if ( 'unhelpful' == value && activity.helpful ) {
 186+ // Allow multiple simultaneous ajax requests in this case.
 187+ $.articleFeedbackv5special.listControls.allowMultiple = true;
182188 $.articleFeedbackv5special.flagFeedback( id, 'helpful', -1 );
183189 $.articleFeedbackv5special.flagFeedback( id, 'unhelpful', 1 );
 190+ $.articleFeedbackv5special.listControls.allowMultiple = false;
184191 } else {
185192 $.articleFeedbackv5special.flagFeedback( id, value, 1 );
186193 }
@@ -473,10 +480,16 @@
474481 return false;
475482 }
476483
477 - // Put a lock on ajax requests to prevent another one from going
478 - // through while this is still running. Prevents manic link-clicking
479 - // messing up the counts, and generally seems like a good idea.
480 - $.articleFeedbackv5special.listControls.disabled = true;
 484+ // This was causing problems with eg 'clicking helpful when the cookie
 485+ // already says unhelpful', which is a case where two ajax requests
 486+ // is perfectly legitimate.
 487+ // Check another global variable to not disable ajax in that case.
 488+ if( !$.articleFeedbackv5special.listControls.allowMultiple ) {
 489+ // Put a lock on ajax requests to prevent another one from going
 490+ // through while this is still running. Prevents manic link-clicking
 491+ // messing up the counts, and generally seems like a good idea.
 492+ $.articleFeedbackv5special.listControls.disabled = true;
 493+ }
481494
482495 $.ajax( {
483496 'url' : $.articleFeedbackv5special.apiUrl,

Status & tagging log