Make WordPress Core

Changeset 24622


Ignore:
Timestamp:
07/10/2013 03:20:58 AM (12 years ago)
Author:
markjaquith
Message:

Don't call updateDiff() in the Revisions FrameState model.

  • Stuff needs to hook in, so firing it early results in a half-rendered screen.
  • updateDiff() now returns a promise.
  • Now, in the frame view's render(), it calls updateDiff(), relying on its promise.

See #24425.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/revisions.js

    r24615 r24622  
    260260            this.listenTo( this, 'update:revisions', this.loadSurrounding );
    261261            this.listenTo( this, 'change:compareTwoMode', this.changedMode );
    262             this.updateDiff({ immediate: true });
    263262        },
    264263
     
    301300            // Check if we're actually changing the diff id.
    302301            if ( this._diffId === diffId )
    303                 return;
     302                return $.Deferred().fail().promise();
    304303
    305304            this._diffId = diffId;
     
    310309            if ( diff ) {
    311310                this.trigger( 'update:diff', diff );
    312 
     311                return $.Deferred().resolve().promise();
    313312            // Otherwise, fetch the diff.
    314313            } else {
    315                 if ( options.immediate )
    316                     this._ensureDiff();
    317                 else
     314                if ( options.immediate ) {
     315                    return this._ensureDiff();
     316                } else {
    318317                    this._debouncedEnsureDiff();
     318                    return $.Deferred().fail().promise();
     319                }
    319320            }
    320321        },
     
    327328
    328329        _ensureDiff: function() {
    329             this.diffs.ensure( this._diffId, this ).done( function( diff ) {
     330            return this.diffs.ensure( this._diffId, this ).done( function( diff ) {
    330331                // Make sure the current diff didn't change while the request was in flight.
    331332                if ( this._diffId === diff.id )
     
    362363
    363364        render: function() {
    364             wp.Backbone.View.prototype.render.apply( this, arguments );
    365 
    366             $('#wpbody-content .wrap').append( this.el );
    367             this.views.ready();
     365            this.model.updateDiff({ immediate: true }).done( _.bind( function() {
     366                wp.Backbone.View.prototype.render.apply( this, arguments );
     367
     368                $('#wpbody-content .wrap').append( this.el );
     369                this.views.ready();
     370            }, this ) );
    368371
    369372            return this;
Note: See TracChangeset for help on using the changeset viewer.