From b3186f8d6a96b7a5072e8f998d0b2507d9d503a7 Mon Sep 17 00:00:00 2001 From: David Lynch Date: Wed, 28 Oct 2020 21:59:32 -0500 Subject: [PATCH] Switching editor modes would switch editor_interface before success/fail Also, stop the dialog-prevent-show event from switching editor_interface just because it's tied to the `editor-switch` feature. Bug: T259673 Change-Id: I2acf9d79add281ed0f62f022e44bb18948ceafc8 --- modules/dt.ui.ReplyWidget.js | 15 ++++++++------- modules/logger.js | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/dt.ui.ReplyWidget.js b/modules/dt.ui.ReplyWidget.js index 7b0b9ebd8..e6a527a32 100644 --- a/modules/dt.ui.ReplyWidget.js +++ b/modules/dt.ui.ReplyWidget.js @@ -349,19 +349,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' - } ); }; /** diff --git a/modules/logger.js b/modules/logger.js index 5fde6f7c9..1c16a6ac4 100644 --- a/modules/logger.js +++ b/modules/logger.js @@ -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'; }