Change the behavior so that type conversions only run inside of Clay.getSettings no ClayConfig.getSettings

This commit is contained in:
Keegan
2016-03-09 11:25:13 +11:00
parent 42fc8f1da4
commit 1af4dfd8ef
6 changed files with 127 additions and 32 deletions
+12 -3
View File
@@ -3,7 +3,8 @@
var configPageHtml = require('./tmp/config-page.html');
var toSource = require('tosource');
var standardComponents = require('./src/scripts/components');
var utils = require('./src/scripts/lib/utils');
var _ = require('./src/scripts/vendor/minified')._;
/**
* @param {Array} config - the Clay config
* @param {function} [customFn] - Custom code to run from the config page. Will run
@@ -149,9 +150,10 @@ Clay.prototype.generateUrl = function() {
/**
* Parse the response from the webviewclosed event data
* @param {string} response
* @param {boolean} [convert=true]
* @returns {Object}
*/
Clay.prototype.getSettings = function(response) {
Clay.prototype.getSettings = function(response, convert) {
// Decode and parse config data as JSON
var settings = {};
@@ -162,7 +164,14 @@ Clay.prototype.getSettings = function(response) {
}
localStorage.setItem('clay-settings', JSON.stringify(settings));
return settings;
if (convert === false) {
return settings;
} else {
return _.mapObj(settings, function(key, value) {
return utils.prepareForAppMessage(value);
});
}
};
/**