mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 08:10:35 +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
|
||||
*/
|
||||
ve.dm.MWWikitextSurfaceFragment.prototype.convertToSource = function ( doc ) {
|
||||
var wikitextPromise;
|
||||
var wikitextPromise, progressPromise;
|
||||
|
||||
if ( !doc.data.hasContent() ) {
|
||||
return $.Deferred().resolve( '' ).promise();
|
||||
|
@ -137,15 +137,21 @@ ve.dm.MWWikitextSurfaceFragment.prototype.convertToSource = function ( doc ) {
|
|||
wikitextPromise = ve.init.target.getWikitextFragment( doc, false );
|
||||
|
||||
// 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' )
|
||||
).done( function ( progressBar, cancelPromise ) {
|
||||
).then( function ( progressBar, cancelPromise ) {
|
||||
cancelPromise.fail( function () {
|
||||
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