Merge "Add an 'api' parameter to ApiResponseCache"

This commit is contained in:
jenkins-bot 2018-05-07 15:53:17 +00:00 committed by Gerrit Code Review
commit 7bca14c182
4 changed files with 16 additions and 7 deletions

View file

@ -14,11 +14,14 @@
* @class
* @extends OO.EventEmitter
* @constructor
* @param {mw.Api} [api] API object to use. Defaults to new mw.Api()
*/
ve.init.mw.ApiResponseCache = function VeInitMwApiResponseCache() {
ve.init.mw.ApiResponseCache = function VeInitMwApiResponseCache( api ) {
// Mixin constructor
OO.EventEmitter.call( this );
this.api = api || new mw.Api();
// Keys are titles, values are deferreds
this.deferreds = {};

View file

@ -11,9 +11,11 @@
* @class
* @extends ve.init.mw.ImageInfoCache
* @constructor
* @param {mw.Api} [api]
*/
ve.init.mw.GalleryImageInfoCache = function VeInitMwGalleryImageInfoCache() {
ve.init.mw.GalleryImageInfoCache.super.call( this );
// Parent constructor
ve.init.mw.GalleryImageInfoCache.super.apply( this, arguments );
};
/* Inheritance */
@ -26,7 +28,7 @@ OO.inheritClass( ve.init.mw.GalleryImageInfoCache, ve.init.mw.ImageInfoCache );
* @inheritdoc
*/
ve.init.mw.GalleryImageInfoCache.prototype.getRequestPromise = function ( subqueue ) {
return new mw.Api().get(
return this.api.get(
{
action: 'query',
prop: 'imageinfo',

View file

@ -11,9 +11,11 @@
* @class
* @extends ve.init.mw.ApiResponseCache
* @constructor
* @param {mw.Api} [api]
*/
ve.init.mw.ImageInfoCache = function VeInitMwImageInfoCache() {
ve.init.mw.ImageInfoCache.super.call( this );
// Parent constructor
ve.init.mw.ImageInfoCache.super.apply( this, arguments );
};
/* Inheritance */
@ -41,7 +43,7 @@ ve.init.mw.ImageInfoCache.static.processPage = function ( page ) {
ve.init.mw.ImageInfoCache.prototype.getRequestPromise = function ( subqueue ) {
// If you change what `iiprop`s are being fetched, update
// ve.ui.MWMediaDialog to add the same ones to the cache.
return new mw.Api().get(
return this.api.get(
{
action: 'query',
prop: 'imageinfo',

View file

@ -11,9 +11,11 @@
* @class
* @extends ve.init.mw.ApiResponseCache
* @constructor
* @param {mw.Api} [api]
*/
ve.init.mw.LinkCache = function VeInitMwLinkCache() {
ve.init.mw.LinkCache.super.call( this );
// Parent constructor
ve.init.mw.LinkCache.super.apply( this, arguments );
// Keys are page names, values are link data objects
// This is kept for synchronous retrieval of cached values via #getCached
@ -184,7 +186,7 @@ ve.init.mw.LinkCache.prototype.get = function ( title ) {
* @inheritdoc
*/
ve.init.mw.LinkCache.prototype.getRequestPromise = function ( subqueue ) {
return new mw.Api().get( {
return this.api.get( {
action: 'query',
prop: 'info|pageprops|pageimages|description',
pithumbsize: 80,