mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-01 01:16:30 +00:00
Only resolve wikitext promise when progress dialog has closed
Logically depends on I0cdb004011 to fix the bug. Bug: T182402 Change-Id: I8ecd695c052a6c759b8261e81fb25c771bdf3d56
This commit is contained in:
parent
58c5643f1e
commit
b38500f102
|
@ -128,7 +128,7 @@ ve.dm.MWWikitextSurfaceFragment.prototype.unwrapText = function ( before, after
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
ve.dm.MWWikitextSurfaceFragment.prototype.convertToSource = function ( doc ) {
|
ve.dm.MWWikitextSurfaceFragment.prototype.convertToSource = function ( doc ) {
|
||||||
var wikitextPromise;
|
var wikitextPromise, progressPromise;
|
||||||
|
|
||||||
if ( !doc.data.hasContent() ) {
|
if ( !doc.data.hasContent() ) {
|
||||||
return $.Deferred().resolve( '' ).promise();
|
return $.Deferred().resolve( '' ).promise();
|
||||||
|
@ -137,15 +137,21 @@ ve.dm.MWWikitextSurfaceFragment.prototype.convertToSource = function ( doc ) {
|
||||||
wikitextPromise = ve.init.target.getWikitextFragment( doc, false );
|
wikitextPromise = ve.init.target.getWikitextFragment( doc, false );
|
||||||
|
|
||||||
// TODO: Emit an event to trigger the progress bar
|
// TODO: Emit an event to trigger the progress bar
|
||||||
ve.init.target.getSurface().createProgress(
|
progressPromise = ve.init.target.getSurface().createProgress(
|
||||||
wikitextPromise, ve.msg( 'visualeditor-generating-wikitext-progress' )
|
wikitextPromise, ve.msg( 'visualeditor-generating-wikitext-progress' )
|
||||||
).done( function ( progressBar, cancelPromise ) {
|
).then( function ( progressBar, cancelPromise ) {
|
||||||
cancelPromise.fail( function () {
|
cancelPromise.fail( function () {
|
||||||
wikitextPromise.abort();
|
wikitextPromise.abort();
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
return wikitextPromise;
|
return $.when( wikitextPromise, progressPromise ).then( function ( wikitext ) {
|
||||||
|
var deferred = $.Deferred();
|
||||||
|
setTimeout( function () {
|
||||||
|
deferred.resolve( wikitext );
|
||||||
|
}, ve.init.target.getSurface().dialogs.getTeardownDelay() );
|
||||||
|
return deferred.promise();
|
||||||
|
} );
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue