Make WordPress Core

Ticket #53171: 53171.3.diff

File 53171.3.diff, 1.9 KB (added by adamsilverstein, 5 years ago)
  • src/js/media/models/attachments.js

    diff --git src/js/media/models/attachments.js src/js/media/models/attachments.js
    index 42b05d7546..8c9ec72922 100644
    var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen 
    212212                this.observers.push( attachments );
    213213
    214214                attachments.on( 'add change remove', this._validateHandler, this );
     215                attachments.on( 'add', this._addToTotalAttachments, this );
     216                attachments.on( 'remove', this._removeFromTotalAttachments, this );
    215217                attachments.on( 'reset', this._validateAllHandler, this );
    216218                this.validateAll( attachments );
    217219                return this;
    var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen 
    236238
    237239                return this;
    238240        },
     241        /**
     242         * Update total attachment count when items are added to a collection.
     243         *
     244         * @access private
     245         *
     246         * @since 5.8.0
     247         *
     248         * @param {wp.media.model.Attachments} attachment
     249         * @param {wp.media.model.Attachments} attachments
     250         * @param {Object} options
     251         *
     252         * @return {wp.media.model.Attachments} Returns itself to allow chaining.
     253         */
     254        _removeFromTotalAttachments: function( attachment, attachments, options ) {
     255                if ( this.mirroring ) {
     256                        this.mirroring.totalAttachments = this.mirroring.totalAttachments - 1;
     257                }
     258        },
     259        /**
     260         * Update total attachment count when items are added to a collection.
     261         *
     262         * @access private
     263         *
     264         * @since 5.8.0
     265         *
     266         * @param {wp.media.model.Attachments} attachment
     267         * @param {wp.media.model.Attachments} attachments
     268         * @param {Object} options
     269         *
     270         * @return {wp.media.model.Attachments} Returns itself to allow chaining.
     271         */
     272        _addToTotalAttachments: function( attachment, attachments, options ) {
     273                if ( this.mirroring ) {
     274                        this.mirroring.totalAttachments = this.mirroring.totalAttachments + 1;
     275                }
     276        },
    239277        /**
    240278         * @access private
    241279         *