File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3956,7 +3956,9 @@ AttachmentsBrowser = View.extend({
39563956 controller : this . controller ,
39573957 priority : - 55 ,
39583958 click : function ( ) {
3959- var removed = [ ] , selection = this . controller . state ( ) . get ( 'selection' ) ;
3959+ var removed = [ ] ,
3960+ destroy = [ ] ,
3961+ selection = this . controller . state ( ) . get ( 'selection' ) ;
39603962
39613963 if ( ! selection . length || ! window . confirm ( l10n . warnBulkDelete ) ) {
39623964 return ;
@@ -3968,11 +3970,20 @@ AttachmentsBrowser = View.extend({
39683970 return ;
39693971 }
39703972
3971- model . destroy ( ) ;
3973+ destroy . push ( model ) ;
39723974 } ) ;
39733975
3974- selection . remove ( removed ) ;
3975- this . controller . trigger ( 'selection:action:done' ) ;
3976+ if ( removed . length ) {
3977+ selection . remove ( removed ) ;
3978+ }
3979+
3980+ if ( destroy . length ) {
3981+ $ . when . apply ( null , destroy . map ( function ( item ) {
3982+ return item . destroy ( ) ;
3983+ } ) ) . then ( _ . bind ( function ( ) {
3984+ this . controller . trigger ( 'selection:action:done' ) ;
3985+ } , this ) ) ;
3986+ }
39763987 }
39773988 } ) . render ( ) ) ;
39783989 }
Original file line number Diff line number Diff line change @@ -225,7 +225,9 @@ AttachmentsBrowser = View.extend({
225225 controller : this . controller ,
226226 priority : - 55 ,
227227 click : function ( ) {
228- var removed = [ ] , selection = this . controller . state ( ) . get ( 'selection' ) ;
228+ var removed = [ ] ,
229+ destroy = [ ] ,
230+ selection = this . controller . state ( ) . get ( 'selection' ) ;
229231
230232 if ( ! selection . length || ! window . confirm ( l10n . warnBulkDelete ) ) {
231233 return ;
@@ -237,11 +239,20 @@ AttachmentsBrowser = View.extend({
237239 return ;
238240 }
239241
240- model . destroy ( ) ;
242+ destroy . push ( model ) ;
241243 } ) ;
242244
243- selection . remove ( removed ) ;
244- this . controller . trigger ( 'selection:action:done' ) ;
245+ if ( removed . length ) {
246+ selection . remove ( removed ) ;
247+ }
248+
249+ if ( destroy . length ) {
250+ $ . when . apply ( null , destroy . map ( function ( item ) {
251+ return item . destroy ( ) ;
252+ } ) ) . then ( _ . bind ( function ( ) {
253+ this . controller . trigger ( 'selection:action:done' ) ;
254+ } , this ) ) ;
255+ }
245256 }
246257 } ) . render ( ) ) ;
247258 }
You can’t perform that action at this time.
0 commit comments