From f188597025ee0d3ad9443d472d009a21789b8813 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 29 Feb 2016 03:19:48 +0000 Subject: [PATCH] Comments: Avoid extra AJAX requests when undoing Spam or Trash actions. Props afercia. Fixes #35904. git-svn-id: https://develop.svn.wordpress.org/trunk@36774 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/edit-comments.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/js/edit-comments.js b/src/wp-admin/js/edit-comments.js index dd3025f194..f201362bf0 100644 --- a/src/wp-admin/js/edit-comments.js +++ b/src/wp-admin/js/edit-comments.js @@ -286,6 +286,7 @@ setCommentsList = function() { a.click(function( e ){ e.preventDefault(); + e.stopPropagation(); // ticket #35904 list.wpList.del(this); $('#undo-' + id).css( {backgroundColor:'#ceb'} ).fadeOut(350, function(){ $(this).remove(); @@ -313,7 +314,8 @@ setCommentsList = function() { approved = commentRow.hasClass( 'approved' ), unapproved = commentRow.hasClass( 'unapproved' ), spammed = commentRow.hasClass( 'spam' ), - trashed = commentRow.hasClass( 'trash' ); + trashed = commentRow.hasClass( 'trash' ), + undoing = false; // ticket #35904 updateDashboardText( newTotal ); @@ -347,6 +349,8 @@ setCommentsList = function() { } } + undoing = true; + // user clicked "Spam" } else if ( targetParent.is( 'span.spam' ) ) { // the comment is currently approved @@ -481,7 +485,7 @@ setCommentsList = function() { } } - if ( ! theExtraList || theExtraList.length === 0 || theExtraList.children().length === 0 ) { + if ( ! theExtraList || theExtraList.length === 0 || theExtraList.children().length === 0 || undoing ) { return; }