Hygiene: Rename builder vars on require preview/model

preview/model is just a module/namespace object, not a builder class or
similar.

This patch changes a couple of imports to reference some of the exposed
functions of the preview/model where required.

In a shiny future, this pattern would be:

    const { createModel, createNullModel } =
      require( '../preview/model' )

Bug: T165018
Change-Id: If6ad4611538ca4f24e2443c0c3ed433275e995a6
This commit is contained in:
joakin 2017-06-15 20:06:31 +02:00
parent 010a4d91a6
commit 98d9415361
4 changed files with 7 additions and 5 deletions

Binary file not shown.

Binary file not shown.

View file

@ -13,7 +13,7 @@
//
// FIXME: Move this to src/constants.js.
var CACHE_LIFETIME = 300,
modelBuilder = require( '../preview/model' ),
createModel = require( '../preview/model' ).createModel,
formatter = require( '../formatter' ),
$ = jQuery;
@ -129,7 +129,7 @@ function formatPlainTextExtract( data ) {
* @returns {PreviewModel}
*/
function convertPageToModel( page ) {
return modelBuilder.createModel(
return createModel(
page.title,
page.canonicalurl,
page.pagelanguagehtmlcode,

View file

@ -4,7 +4,9 @@
var RESTBASE_ENDPOINT = '/api/rest_v1/page/summary/',
RESTBASE_PROFILE = 'https://www.mediawiki.org/wiki/Specs/Summary/1.2.0',
modelBuilder = require( '../preview/model' ),
model = require( '../preview/model' ),
createModel = model.createModel,
createNullModel = model.createNullModel,
mw = window.mediaWiki,
$ = jQuery;
/**
@ -65,7 +67,7 @@ module.exports = function createRESTBaseGateway( ajax, config, extractParser ) {
if ( jqXHR.status === 404 ) {
result.resolve(
modelBuilder.createNullModel( title )
createNullModel( title )
);
} else {
result.reject();
@ -147,7 +149,7 @@ function generateThumbnailData( thumbnail, original, thumbSize ) {
* @returns {PreviewModel}
*/
function convertPageToModel( page, thumbSize, extractParser ) {
return modelBuilder.createModel(
return createModel(
page.title,
new mw.Title( page.title ).getUrl(),
page.lang,