Clear VE autosave whenever WikiEditor is loaded

Bug: T189381
Change-Id: I21a76dc32327d6c6e72a793d9b579cb7b6a5e32e
This commit is contained in:
Ed Sanders 2018-03-10 18:30:12 +00:00
parent ec6d9b235a
commit c3c3c60f1f

View file

@ -1111,10 +1111,11 @@
);
}
// Add the switch button to wikitext ?action=edit or ?action=submit pages
// Add the switch button to WikiEditor on ?action=edit or ?action=submit pages
if (
init.isVisualAvailable &&
[ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1
[ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 &&
$( '#wpTextbox1' ).length
) {
mw.loader.load( 'ext.visualEditor.switching' );
$( '#wpTextbox1' ).on( 'wikiEditor-toolbar-doneInitialSections', function () {
@ -1176,6 +1177,12 @@
// Remember that the user wanted wikitext, at least this time
mw.libs.ve.setEditorPreference( 'wikitext' );
// If the user has loaded WikiEditor, clear any auto-save state they
// may have from a previous VE session
// We don't have access to the VE session storage methods, but invalidating
// the docstate is sufficient to prevent the data from being used.
mw.storage.session.remove( 've-docstate' );
}
init.setupEditLinks();