Skip to content

Commit c9601fd

Browse files
committed
fix: jshint lint errors
1 parent e629821 commit c9601fd

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

src/js/media/models/attachment.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -184,22 +184,17 @@ Attachment = Backbone.Model.extend(/** @lends wp.media.model.Attachment.prototyp
184184
batchSize = batchSize || 50;
185185

186186
var promises = [],
187-
i, slice, ids, nonces;
187+
i, slice, data;
188188

189189
for ( i = 0; i < models.length; i += batchSize ) {
190-
slice = models.slice( i, i + batchSize );
191-
ids = [];
192-
nonces = {};
193-
194-
_.each( slice, function( model ) {
195-
ids.push( model.id );
196-
nonces[ model.id ] = model.get( 'nonces' )['delete'];
197-
});
198-
199-
promises.push( wp.media.post( 'delete-post-batch', {
200-
ids: ids,
201-
nonces: nonces
202-
}) );
190+
slice = models.slice( i, i + batchSize );
191+
data = _.reduce( slice, function( acc, model ) {
192+
acc.ids.push( model.id );
193+
acc.nonces[ model.id ] = model.get( 'nonces' )['delete'];
194+
return acc;
195+
}, { ids: [], nonces: {} } );
196+
197+
promises.push( wp.media.post( 'delete-post-batch', data ) );
203198
}
204199

205200
return $.when.apply( null, promises ).then( function() {

0 commit comments

Comments
 (0)