diff --git a/lib/cartodb/controllers/map.js b/lib/cartodb/controllers/map.js index 8e68e9fd..f97f4d3d 100644 --- a/lib/cartodb/controllers/map.js +++ b/lib/cartodb/controllers/map.js @@ -210,15 +210,11 @@ MapController.prototype.create = function(req, res, prepareConfigFn) { assert.ifError(err); var next = this; - self.turboCartoAdapter.getLayers(req.context.user, requestMapConfig.layers, function (err, layers) { + self.turboCartoAdapter.getMapConfig(req.context.user, requestMapConfig, function (err, requestMapConfig) { if (err) { return next(err); } - if (layers) { - requestMapConfig.layers = layers; - } - return next(null, requestMapConfig, datasource); }); }, diff --git a/lib/cartodb/models/mapconfig/adapter/turbo-carto-adapter.js b/lib/cartodb/models/mapconfig/adapter/turbo-carto-adapter.js index f7a40a0c..fd2b0c20 100644 --- a/lib/cartodb/models/mapconfig/adapter/turbo-carto-adapter.js +++ b/lib/cartodb/models/mapconfig/adapter/turbo-carto-adapter.js @@ -11,11 +11,13 @@ function TurboCartoAdapter(turboCartoParser) { module.exports = TurboCartoAdapter; -TurboCartoAdapter.prototype.getLayers = function (username, layers, callback) { +TurboCartoAdapter.prototype.getMapConfig = function (username, requestMapConfig, callback) { var self = this; + var layers = requestMapConfig.layers; + if (!layers || layers.length === 0) { - return callback(null, layers); + return callback(null, requestMapConfig); } var parseCartoQueue = queue(layers.length); @@ -29,7 +31,9 @@ TurboCartoAdapter.prototype.getLayers = function (username, layers, callback) { return callback(err); } - return callback(null, layers); + requestMapConfig.layers = layers; + + return callback(null, requestMapConfig); }); }; diff --git a/lib/cartodb/models/mapconfig/provider/named-map-provider.js b/lib/cartodb/models/mapconfig/provider/named-map-provider.js index e05998e1..aed00af7 100644 --- a/lib/cartodb/models/mapconfig/provider/named-map-provider.js +++ b/lib/cartodb/models/mapconfig/provider/named-map-provider.js @@ -164,15 +164,11 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) { assert.ifError(err); var next = this; - self.turboCartoAdapter.getLayers(self.owner, _mapConfig.layers, function (err, layers) { + self.turboCartoAdapter.getMapConfig(self.owner, _mapConfig, function (err, _mapConfig) { if (err) { return next(err); } - if (layers) { - _mapConfig.layers = layers; - } - return next(null, _mapConfig, datasource); }); },