mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-25 11:16:51 +00:00
Don't bother fetching metadata for diffs
Only HTML content is used for building diffs Change-Id: I4f9af162792c27e7771838b6294c106bc9dc359a
This commit is contained in:
parent
f213e370f7
commit
e6bb954edd
|
@ -197,9 +197,11 @@
|
||||||
* @param {string} pageName See #requestPageData
|
* @param {string} pageName See #requestPageData
|
||||||
* @param {Object} [options] See #requestPageData
|
* @param {Object} [options] See #requestPageData
|
||||||
* @param {boolean} [noRestbase=false] Don't query RESTBase directly
|
* @param {boolean} [noRestbase=false] Don't query RESTBase directly
|
||||||
|
* @param {boolean} [noMetadata=false] Don't fetch document metadata when querying RESTBase. Metadata
|
||||||
|
* is not required for some use cases, e.g. diffing.
|
||||||
* @return {jQuery.Promise} Abortable promise resolved with a JSON object
|
* @return {jQuery.Promise} Abortable promise resolved with a JSON object
|
||||||
*/
|
*/
|
||||||
requestParsoidData: function ( pageName, options, noRestbase ) {
|
requestParsoidData: function ( pageName, options, noRestbase, noMetadata ) {
|
||||||
var start, apiXhr, restbaseXhr, apiPromise, restbasePromise, dataPromise, pageHtmlUrl, headers, data, abort,
|
var start, apiXhr, restbaseXhr, apiPromise, restbasePromise, dataPromise, pageHtmlUrl, headers, data, abort,
|
||||||
section = options.section !== undefined ? options.section : null,
|
section = options.section !== undefined ? options.section : null,
|
||||||
useRestbase = !noRestbase && ( conf.fullRestbaseUrl || conf.restbaseUrl ) && section === null,
|
useRestbase = !noRestbase && ( conf.fullRestbaseUrl || conf.restbaseUrl ) && section === null,
|
||||||
|
@ -241,23 +243,29 @@
|
||||||
data.oldid = options.oldId;
|
data.oldid = options.oldId;
|
||||||
apiXhr = new mw.Api().post( data );
|
apiXhr = new mw.Api().post( data );
|
||||||
} else {
|
} else {
|
||||||
apiXhr = new mw.Api().get( data );
|
if ( noMetadata ) {
|
||||||
}
|
apiPromise = $.Deferred().resolve( { visualeditor: {} } ).promise();
|
||||||
apiPromise = apiXhr.then( function ( data, jqxhr ) {
|
} else {
|
||||||
ve.track( 'trace.apiLoad.exit', { mode: 'visual' } );
|
apiXhr = new mw.Api().get( data );
|
||||||
ve.track( 'mwtiming.performance.system.apiLoad', {
|
|
||||||
bytes: require( 'mediawiki.String' ).byteLength( jqxhr.responseText ),
|
|
||||||
duration: ve.now() - start,
|
|
||||||
cacheHit: /hit/i.test( jqxhr.getResponseHeader( 'X-Cache' ) ),
|
|
||||||
targetName: options.targetName,
|
|
||||||
mode: 'visual'
|
|
||||||
} );
|
|
||||||
if ( data.visualeditor ) {
|
|
||||||
data.visualeditor.switched = switched;
|
|
||||||
data.visualeditor.fromEditedState = fromEditedState;
|
|
||||||
}
|
}
|
||||||
return data;
|
}
|
||||||
} );
|
if ( !apiPromise ) {
|
||||||
|
apiPromise = apiXhr.then( function ( data, jqxhr ) {
|
||||||
|
ve.track( 'trace.apiLoad.exit', { mode: 'visual' } );
|
||||||
|
ve.track( 'mwtiming.performance.system.apiLoad', {
|
||||||
|
bytes: require( 'mediawiki.String' ).byteLength( jqxhr.responseText ),
|
||||||
|
duration: ve.now() - start,
|
||||||
|
cacheHit: /hit/i.test( jqxhr.getResponseHeader( 'X-Cache' ) ),
|
||||||
|
targetName: options.targetName,
|
||||||
|
mode: 'visual'
|
||||||
|
} );
|
||||||
|
if ( data.visualeditor ) {
|
||||||
|
data.visualeditor.switched = switched;
|
||||||
|
data.visualeditor.fromEditedState = fromEditedState;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
if ( useRestbase ) {
|
if ( useRestbase ) {
|
||||||
ve.track( 'trace.restbaseLoad.enter', { mode: 'visual' } );
|
ve.track( 'trace.restbaseLoad.enter', { mode: 'visual' } );
|
||||||
|
|
|
@ -65,7 +65,13 @@
|
||||||
cacheKey = revId + ( section !== null ? '/' + section : '' );
|
cacheKey = revId + ( section !== null ? '/' + section : '' );
|
||||||
|
|
||||||
revCache[ cacheKey ] = revCache[ cacheKey ] ||
|
revCache[ cacheKey ] = revCache[ cacheKey ] ||
|
||||||
mw.libs.ve.targetLoader.requestParsoidData( pageName, { oldId: revId, targetName: 'diff' } ).then( function ( response ) {
|
mw.libs.ve.targetLoader.requestParsoidData(
|
||||||
|
pageName,
|
||||||
|
{ oldId: revId, targetName: 'diff' },
|
||||||
|
false,
|
||||||
|
// noMetadata, we only use `content` in getModelFromResponse
|
||||||
|
true
|
||||||
|
).then( function ( response ) {
|
||||||
return parseDocumentModulePromise.then( function () {
|
return parseDocumentModulePromise.then( function () {
|
||||||
return mw.libs.ve.diffLoader.getModelFromResponse( response, section );
|
return mw.libs.ve.diffLoader.getModelFromResponse( response, section );
|
||||||
} );
|
} );
|
||||||
|
|
Loading…
Reference in a new issue