From 37b81b5ba411829783b7a707caa15c4f2dc0ab0d Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Fri, 13 May 2022 22:36:50 +0100 Subject: [PATCH] ArticleTarget: Always reload the page after save on non-view page This is currently only handled in DesktopArticleTarget in teardown, which happens after we've wasted time trying to update the page. Also ensure we always reload on non-view pages on MobileArticleTarget for other types of teardown (e.g. quitting the editor). Change-Id: I7fb352fcacc8727bb113115e98af38a3940a8f9c --- .../init/targets/ve.init.mw.ArticleTarget.js | 8 +++++--- .../targets/ve.init.mw.MobileArticleTarget.js | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js b/modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js index a8f00f9d41..5bd5ac8468 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js @@ -628,12 +628,14 @@ ve.init.mw.ArticleTarget.prototype.saveComplete = function ( data ) { var target = this; - if ( !this.pageExists || this.restoring ) { + // This is a page creation, a restoration, or we loaded the editor from a non-view page: refresh the page. + if ( !this.pageExists || this.restoring || !this.isViewPage ) { // Teardown the target, ensuring auto-save data is cleared this.teardown().then( function () { - // This is a page creation or restoration, refresh the page - var newUrlParams = data.newrevid === undefined ? {} : { venotify: target.restoring ? 'restored' : 'created' }; + var newUrlParams = !this.pageExists || this.restoring ? + ( data.newrevid === undefined ? {} : { venotify: target.restoring ? 'restored' : 'created' } ) : + {}; if ( data.isRedirect ) { newUrlParams.redirect = 'no'; diff --git a/modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js b/modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js index 58d1eaf0ee..8cc277fee3 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js @@ -438,6 +438,21 @@ ve.init.mw.MobileArticleTarget.prototype.tryTeardown = function () { this.overlay.onExitClick( $.Event() ); }; +/** + * @inheritdoc + */ +ve.init.mw.MobileArticleTarget.prototype.teardown = function () { + var target = this; + // Parent method + return ve.init.mw.MobileArticleTarget.super.prototype.teardown.call( this ).then( function () { + if ( !target.isViewPage ) { + location.href = target.viewUri.clone().extend( { + redirect: mw.config.get( 'wgIsRedirect' ) ? 'no' : undefined + } ); + } + } ); +}; + /** * @inheritdoc */