Media: in `wp.media.view.DeleteSelectedPermanentlyButton`, move destructive async operations outside of the `selection` loop.

Fixes #39780.

Built from https://develop.svn.wordpress.org/trunk@40051


git-svn-id: http://core.svn.wordpress.org/trunk@39988 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2017-02-08 19:44:41 +00:00
parent 907e8cbd66
commit 9bf3844ef9
3 changed files with 19 additions and 8 deletions

View File

@ -3956,7 +3956,9 @@ AttachmentsBrowser = View.extend({
controller: this.controller,
priority: -55,
click: function() {
var removed = [], selection = this.controller.state().get( 'selection' );
var removed = [],
destroy = [],
selection = this.controller.state().get( 'selection' );
if ( ! selection.length || ! window.confirm( l10n.warnBulkDelete ) ) {
return;
@ -3968,11 +3970,20 @@ AttachmentsBrowser = View.extend({
return;
}
model.destroy();
destroy.push( model );
} );
selection.remove( removed );
this.controller.trigger( 'selection:action:done' );
if ( removed.length ) {
selection.remove( removed );
}
if ( destroy.length ) {
$.when.apply( null, destroy.map( function (item) {
return item.destroy();
} ) ).then( _.bind( function() {
this.controller.trigger( 'selection:action:done' );
}, this ) );
}
}
}).render() );
}

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8-alpha-40050';
$wp_version = '4.8-alpha-40051';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.