* Use lodash for Config.js / config.json merge

This commit is contained in:
Bryan Ashby 2015-08-05 22:22:17 -06:00
parent ab40eb1fd4
commit 82f3bc7601
3 changed files with 22 additions and 25 deletions

View File

@ -107,6 +107,7 @@ function Client(input, output) {
// //
// Every 1m, check for idle. // Every 1m, check for idle.
// //
console.log('idleLogoutSeconds=' + Config.misc.idleLogoutSeconds)
this.idleCheck = setInterval(function checkForIdle() { this.idleCheck = setInterval(function checkForIdle() {
var nowMs = Date.now(); var nowMs = Date.now();

View File

@ -13,24 +13,6 @@ exports.init = init;
exports.getDefaultPath = getDefaultPath; exports.getDefaultPath = getDefaultPath;
function init(configPath, cb) { function init(configPath, cb) {
// Probably many better ways of doing this:
// :TODO: See http://jsfiddle.net/jlowery2663/z8at6knn/4/
var recursiveMerge = function(target, source) {
for(var p in source) {
try {
if(_.isObject(source)) {
target[p] = recursiveMerge(target[p], source[p]);
} else {
target[p] = source[p];
}
} catch(e) {
target[p] = source[p];
}
}
return target;
};
async.waterfall( async.waterfall(
[ [
function loadUserConfig(callback) { function loadUserConfig(callback) {
@ -48,8 +30,8 @@ function init(configPath, cb) {
} }
}); });
}, },
function mergeWithDefaultConfig(menuConfig, callback) { function mergeWithDefaultConfig(configJson, callback) {
var mergedConfig = recursiveMerge(menuConfig, getDefaultConfig()); var mergedConfig = _.defaultsDeep(configJson, getDefaultConfig());
callback(null, mergedConfig); callback(null, mergedConfig);
} }
], ],

View File

@ -34,8 +34,14 @@ function FullScreenEditorModule(options) {
this.artNames = [ 'header', 'body', 'footerEdit', 'footerEditMenu', 'footerView' ]; this.artNames = [ 'header', 'body', 'footerEdit', 'footerEditMenu', 'footerView' ];
// :TODO: This needs to be passed in via args: // :TODO: The following needs to be passed in via args:
this.editorMode = 'edit'; // view | edit | editMenu | this.editorMode = 'edit'; // view | edit | editMenu |
this.isLocal = true;
this.toUserId = options.toUserId || 0;
this.fromUserId = options.fromUserId || 0;
// netMail/crashMail | echoMail // netMail/crashMail | echoMail
this.messageAreaId = 'netMail' === this.editorType ? Message.WellKnownAreaIds.Private : options.messageAreaId; this.messageAreaId = 'netMail' === this.editorType ? Message.WellKnownAreaIds.Private : options.messageAreaId;
@ -66,15 +72,23 @@ function FullScreenEditorModule(options) {
fromUserName : headerValues.from, fromUserName : headerValues.from,
subject : headerValues.subject, subject : headerValues.subject,
message : self.viewControllers.body.getFormData().value.message, message : self.viewControllers.body.getFormData().value.message,
}; };
console.log(messageOpts); console.log(messageOpts);
/*var msg = new Message(messageOpts); var msg = new Message(messageOpts);
msg.persist(function persisted(err, msgId) {
if(self.isLocal) {
msg.meta.System.local_to_user_id = self.toUserId;
msg.meta.System.local_from_user_id = self.fromUserId;
}
/*msg.persist(function persisted(err, msgId) {
});*/
});
*/
}; };
this.redrawFooter = function(options, cb) { this.redrawFooter = function(options, cb) {