use assign in place of merge, make sure references to tavern and mods are not lost

This commit is contained in:
Matteo Pagliazzi
2015-08-14 22:02:19 +02:00
parent 2e1b046701
commit b31966b1ee
3 changed files with 6 additions and 4 deletions

View File

@@ -43,7 +43,7 @@ module.exports = function(req, res, next) {
// Load moment.js language file only when not on static pages
language.momentLang = ((!isStaticPage && i18n.momentLangs[language.code]) || undefined);
res.locals.habitrpg = _.merge(env, {
res.locals.habitrpg = _.assign(env, {
IS_MOBILE: /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(req.header('User-Agent')),
language: language,
isStaticPage: isStaticPage,

View File

@@ -236,7 +236,8 @@ module.exports.tavern = {};
var tavernQ = {_id:'habitrpg','quest.key':{$ne:null}};
process.nextTick(function(){
mongoose.model('Group').findOne(tavernQ,function(err,tavern){
module.exports.tavern = tavern;
// Using _assign so we don't lose the reference to the exported tavern
_.assign(module.exports.tavern, tavern);
});
})
GroupSchema.statics.tavernBoss = function(user,progress) {

View File

@@ -580,12 +580,13 @@ module.exports.model = mongoose.model("User", UserSchema);
// Initially export an empty object so external requires will get
// the right object by reference when it's defined later
// Otherwise it would remain undefined if requested before the query executes
module.exports.mods = {};
module.exports.mods = [];
mongoose.model("User")
.find({'contributor.admin':true})
.sort('-contributor.level -backer.npc profile.name')
.select('profile contributor backer')
.exec(function(err,mods){
module.exports.mods = mods
// Using push to maintain the reference to mods
module.exports.mods.push.apply(module.exports.mods, mods);
});