Media: in `wp.media.view.DeleteSelectedPermanentlyButton`, move destructive async operations outside of the `selection` loop.
Fixes #39780. git-svn-id: https://develop.svn.wordpress.org/trunk@40051 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
baff296dfa
commit
87364b0586
|
@ -3956,7 +3956,9 @@ AttachmentsBrowser = View.extend({
|
||||||
controller: this.controller,
|
controller: this.controller,
|
||||||
priority: -55,
|
priority: -55,
|
||||||
click: function() {
|
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 ) ) {
|
if ( ! selection.length || ! window.confirm( l10n.warnBulkDelete ) ) {
|
||||||
return;
|
return;
|
||||||
|
@ -3968,11 +3970,20 @@ AttachmentsBrowser = View.extend({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
model.destroy();
|
destroy.push( model );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
selection.remove( removed );
|
if ( removed.length ) {
|
||||||
this.controller.trigger( 'selection:action:done' );
|
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() );
|
}).render() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,7 +225,9 @@ AttachmentsBrowser = View.extend({
|
||||||
controller: this.controller,
|
controller: this.controller,
|
||||||
priority: -55,
|
priority: -55,
|
||||||
click: function() {
|
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 ) ) {
|
if ( ! selection.length || ! window.confirm( l10n.warnBulkDelete ) ) {
|
||||||
return;
|
return;
|
||||||
|
@ -237,11 +239,20 @@ AttachmentsBrowser = View.extend({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
model.destroy();
|
destroy.push( model );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
selection.remove( removed );
|
if ( removed.length ) {
|
||||||
this.controller.trigger( 'selection:action:done' );
|
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() );
|
}).render() );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue