On a wiki or with an account where I've not used VisualEditor before (or where preferred editor is set to source editor), switching to VisualEditor results in two api.php requests quickly after one another:
Network activity:
- After 1.5s, from setEditorPreference(), from ve.init.mw.DesktopArticleTarget.init's initial $() handler
// ve.init.mw.DesktopArticleTarget.init $(function () { /* .. */ if ( init.isAvailable ) { /* .. */ if ( init.isVisualAvailable && [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) { /* .. */ // Remember that the user wanted wikitext, at least this time mw.libs.ve.setEditorPreference( 'wikitext' );
POST https://ko.wikipedia.org/w/api.php action: options format: json formatversion: 2 change: visualeditor-editor=wikitext token: ***
- After 3.0s, from requestParsoidData(). GET https://ko.wikipedia.org/w/api.php?action=visualeditor&format=json&paction=metadata
- After 3.0s, from requestParsoidData(). POST https://ko.wikipedia.org/api/rest_v1/transform/wikitext/to/html/%EC%82%AC%EC%9A%A9%EC%9E%90%3AKrinkle/0
- After 3.1s, from setEditorPreference , from activateTarget(), from OO.ui.mixin.ButtonElement.onClick.
function activateTarget(mode, ) { /* .. */ if (mode === 'visual') { setEditorPreference('visualeditor');
POST https://ko.wikipedia.org/w/api.php action: options format: json formatversion: 2 change: visualeditor-editor=visualeditor token: ***
This consistently happens using the following steps:
- On Preferences, set edit mode to source editor.
- Go to a page, edit, and switch to visual editor.
- Observe two requests to set opposing values.
The first one shouldn't have happened as the preference was already set to wikitext. (Race condition?) And depending on whether it is intentional that the preference is changed (or only when remembering?) The second one either shouldn't happen either, or should happen earlier (in place of the first one).