r110957 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110956‎ | r110957 | r110958 >
Date:19:58, 8 February 2012
Author:gregchiasson
Status:ok
Tags:aft, nodeploy 
Comment:
AFT5: In flagFeedback, disable ajax requests while there's already one in progress. Prevents a flurry of link clicks jacking up the counts, and at least attempts to avoid a multiple requests piling up and interfering with each other.
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
@@ -52,7 +52,8 @@
5353 sortDirection: 'desc',
5454 limit: 25,
5555 continue: null,
56 - continueId: null // Sort of a tie-breaker for continue values.
 56+ continueId: null, // Sort of a tie-breaker for continue values.
 57+ disabled: false // Prevent (or at least limit) a flood of ajax requests.
5758 };
5859
5960 /**
@@ -468,6 +469,15 @@
469470 * @param dir int the direction of the mark (-1 = tick down; 1 = tick up)
470471 */
471472 $.articleFeedbackv5special.flagFeedback = function ( id, type, dir ) {
 473+ if( $.articleFeedbackv5special.listControls.disabled ) {
 474+ return false;
 475+ }
 476+
 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;
 481+
472482 $.ajax( {
473483 'url' : $.articleFeedbackv5special.apiUrl,
474484 'type' : 'POST',
@@ -550,9 +560,13 @@
551561 }
552562 }
553563 }
 564+ // Re-enable ajax flagging.
 565+ $.articleFeedbackv5special.listControls.disabled = false;
554566 },
555567 'error': function ( data ) {
556568 $( '#articleFeedbackv5-' + type + '-link-' + id ).text( mw.msg( 'articlefeedbackv5-error-flagging' ) );
 569+ // Re-enable ajax flagging.
 570+ $.articleFeedbackv5special.listControls.disabled = false;
557571 }
558572 } );
559573 return false;

Status & tagging log