ArticleTarget: Simplify switching to NWE with no changes

This code was identical to what happens if you just call
reloadSurface(), except for some half-hearted error handling.
We already do it this way when switching from NWE to VE.

Change-Id: I8027680b7ca272930b951d0403594679ef308083
This commit is contained in:
Bartosz Dziewoński 2023-06-20 10:02:23 +02:00
parent d8c3d007ff
commit 3008aaf325

View file

@ -2213,8 +2213,6 @@ ve.init.mw.ArticleTarget.prototype.getSectionHashFromPage = function () {
* @param {boolean} [modified=false] Whether there were any changes at all.
*/
ve.init.mw.ArticleTarget.prototype.switchToWikitextEditor = function ( modified ) {
var target = this;
// When switching with changes we always pass the full page as changes in visual section mode
// can still affect the whole document (e.g. removing a reference)
if ( modified ) {
@ -2222,24 +2220,12 @@ ve.init.mw.ArticleTarget.prototype.switchToWikitextEditor = function ( modified
}
if ( this.isModeAvailable( 'source' ) ) {
var dataPromise;
if ( !modified ) {
dataPromise = mw.libs.ve.targetLoader.requestPageData( 'source', this.getPageName(), {
sessionStore: true,
section: this.section,
oldId: this.requestedRevId,
targetName: this.constructor.static.trackingName
} ).then(
function ( response ) { return response; },
function () {
// TODO: Some sort of progress bar?
return target.switchToFallbackWikitextEditor( modified );
}
);
this.reloadSurface( 'source' );
} else {
dataPromise = this.getWikitextDataPromiseForDoc( modified );
var dataPromise = this.getWikitextDataPromiseForDoc( modified );
this.reloadSurface( 'source', dataPromise );
}
this.reloadSurface( 'source', dataPromise );
} else {
this.switchToFallbackWikitextEditor( modified );
}