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. git-svn-id: https://develop.svn.wordpress.org/trunk@24622 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1b035dc715
commit
e62170f6e2
@ -259,7 +259,6 @@ window.wp = window.wp || {};
|
||||
this.listenTo( this, 'change:to', this.changeRevisionHandler );
|
||||
this.listenTo( this, 'update:revisions', this.loadSurrounding );
|
||||
this.listenTo( this, 'change:compareTwoMode', this.changedMode );
|
||||
this.updateDiff({ immediate: true });
|
||||
},
|
||||
|
||||
changedMode: function() {
|
||||
@ -300,7 +299,7 @@ window.wp = window.wp || {};
|
||||
|
||||
// Check if we're actually changing the diff id.
|
||||
if ( this._diffId === diffId )
|
||||
return;
|
||||
return $.Deferred().fail().promise();
|
||||
|
||||
this._diffId = diffId;
|
||||
this.trigger( 'update:revisions', from, to );
|
||||
@ -309,13 +308,15 @@ window.wp = window.wp || {};
|
||||
diff = this.diffs.get( diffId );
|
||||
if ( diff ) {
|
||||
this.trigger( 'update:diff', diff );
|
||||
|
||||
return $.Deferred().resolve().promise();
|
||||
// Otherwise, fetch the diff.
|
||||
} else {
|
||||
if ( options.immediate )
|
||||
this._ensureDiff();
|
||||
else
|
||||
if ( options.immediate ) {
|
||||
return this._ensureDiff();
|
||||
} else {
|
||||
this._debouncedEnsureDiff();
|
||||
return $.Deferred().fail().promise();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -326,7 +327,7 @@ window.wp = window.wp || {};
|
||||
},
|
||||
|
||||
_ensureDiff: function() {
|
||||
this.diffs.ensure( this._diffId, this ).done( function( diff ) {
|
||||
return this.diffs.ensure( this._diffId, this ).done( function( diff ) {
|
||||
// Make sure the current diff didn't change while the request was in flight.
|
||||
if ( this._diffId === diff.id )
|
||||
this.trigger( 'update:diff', diff );
|
||||
@ -361,10 +362,12 @@ window.wp = window.wp || {};
|
||||
},
|
||||
|
||||
render: function() {
|
||||
wp.Backbone.View.prototype.render.apply( this, arguments );
|
||||
this.model.updateDiff({ immediate: true }).done( _.bind( function() {
|
||||
wp.Backbone.View.prototype.render.apply( this, arguments );
|
||||
|
||||
$('#wpbody-content .wrap').append( this.el );
|
||||
this.views.ready();
|
||||
$('#wpbody-content .wrap').append( this.el );
|
||||
this.views.ready();
|
||||
}, this ) );
|
||||
|
||||
return this;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user