Merge "Switching editor modes would switch editor_interface before success/fail"

This commit is contained in:
jenkins-bot 2020-10-30 23:19:06 +00:00 committed by Gerrit Code Review
commit f3c5d405b3
2 changed files with 10 additions and 8 deletions

View file

@ -350,19 +350,20 @@ ReplyWidget.prototype.onModeTabSelectChoose = function ( option ) {
// TODO: We rely on #setup to call #saveEditMode, so when we have 2017WTE
// we will need to save the new preference here as switching will not
// reload the editor.
promise.then( null, function () {
promise.then( function () {
// Switch succeeded
mw.track( 'dt.schemaVisualEditorFeatureUse', {
feature: 'editor-switch',
// TODO: Log as `source-nwe-desktop` when enable2017Wikitext is set
action: ( mode === 'visual' ? 'visual' : 'source' ) + '-desktop'
} );
}, function () {
// Switch failed, restore previous tab selection
widget.modeTabSelect.selectItemByData( mode === 'source' ? 'visual' : 'source' );
} ).always( function () {
widget.setPending( false );
widget.modeTabSelect.setDisabled( false );
} );
mw.track( 'dt.schemaVisualEditorFeatureUse', {
feature: 'editor-switch',
// TODO: Log as `source-nwe-desktop` when enable2017Wikitext is set
action: ( mode === 'visual' ? 'visual' : 'source' ) + '-desktop'
} );
};
/**

View file

@ -224,7 +224,8 @@ mw.loader.using( 'ext.eventLogging' ).done( function () {
) ? 1 : sampleRate );
}
if ( data.feature === 'editor-switch' ) {
if ( data.feature === 'editor-switch' && data.action.indexOf( 'dialog-' ) === -1 ) {
// TODO: Account for `source-nwe-desktop` when enable2017Wikitext is set
// eslint-disable-next-line camelcase
session.editor_interface = session.editor_interface === 'visualeditor' ? 'wikitext' : 'visualeditor';
}