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
This commit is contained in:
Sergey Biryukov 2016-02-29 03:19:48 +00:00
parent ea2d437b6b
commit f188597025

View File

@ -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;
}