From c0ad11b96067d3a39a9a38ffa6e92825d04d298b Mon Sep 17 00:00:00 2001 From: Adam Wight Date: Tue, 18 Feb 2020 10:42:21 +0100 Subject: [PATCH] Purge autosave before submitting merged content When using TwoColConflict with VisualEditor, the autosave buffer wouldn't be cleared after saving the successful merge. This would cause a user to see a "restore changes?" prompt the next time they entered the editor, with the potential to confuse them and cause them to do extra work, repeating the conflict resolution unnecessarily. This change purges the autosave buffer before submitting a merge. Note that it is not transactional, so there is a chance we're losing the autosaved content even if the submit will fail. Bug: T245119 Change-Id: I150023f548c5565412769d644a828176f907bc25 --- modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 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 24be8e6800..ce5c47d6db 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js @@ -1578,6 +1578,9 @@ ve.init.mw.ArticleTarget.prototype.submit = function ( wikitext, fields ) { if ( this.submitting ) { return false; } + // Clear autosave now that we don't expect to need it again. + // FIXME: This isn't transactional, so if the save fails we're left with no recourse. + this.clearDocState(); // Save DOM this.submitting = true; $form = $( '
' ).attr( { method: 'post', enctype: 'multipart/form-data' } ).addClass( 'oo-ui-element-hidden' ); @@ -2228,12 +2231,7 @@ ve.init.mw.ArticleTarget.prototype.getWikitextDataPromiseForDoc = function ( mod * * @param {boolean} [modified] Whether there were any changes at all. */ -ve.init.mw.ArticleTarget.prototype.switchToFallbackWikitextEditor = function () { - // Assume the fallback editor won't support VE auto-save. Changes need to - // be wiped in case the user makes changes in the other editor then comes - // back to VE. - this.clearDocState(); -}; +ve.init.mw.ArticleTarget.prototype.switchToFallbackWikitextEditor = function () {}; /** * Switch to the visual editor.