mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
use assign in place of merge, make sure references to tavern and mods are not lost
This commit is contained in:
@@ -43,7 +43,7 @@ module.exports = function(req, res, next) {
|
|||||||
// Load moment.js language file only when not on static pages
|
// Load moment.js language file only when not on static pages
|
||||||
language.momentLang = ((!isStaticPage && i18n.momentLangs[language.code]) || undefined);
|
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')),
|
IS_MOBILE: /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(req.header('User-Agent')),
|
||||||
language: language,
|
language: language,
|
||||||
isStaticPage: isStaticPage,
|
isStaticPage: isStaticPage,
|
||||||
|
|||||||
@@ -236,7 +236,8 @@ module.exports.tavern = {};
|
|||||||
var tavernQ = {_id:'habitrpg','quest.key':{$ne:null}};
|
var tavernQ = {_id:'habitrpg','quest.key':{$ne:null}};
|
||||||
process.nextTick(function(){
|
process.nextTick(function(){
|
||||||
mongoose.model('Group').findOne(tavernQ,function(err,tavern){
|
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) {
|
GroupSchema.statics.tavernBoss = function(user,progress) {
|
||||||
|
|||||||
@@ -580,12 +580,13 @@ module.exports.model = mongoose.model("User", UserSchema);
|
|||||||
// Initially export an empty object so external requires will get
|
// Initially export an empty object so external requires will get
|
||||||
// the right object by reference when it's defined later
|
// the right object by reference when it's defined later
|
||||||
// Otherwise it would remain undefined if requested before the query executes
|
// Otherwise it would remain undefined if requested before the query executes
|
||||||
module.exports.mods = {};
|
module.exports.mods = [];
|
||||||
|
|
||||||
mongoose.model("User")
|
mongoose.model("User")
|
||||||
.find({'contributor.admin':true})
|
.find({'contributor.admin':true})
|
||||||
.sort('-contributor.level -backer.npc profile.name')
|
.sort('-contributor.level -backer.npc profile.name')
|
||||||
.select('profile contributor backer')
|
.select('profile contributor backer')
|
||||||
.exec(function(err,mods){
|
.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);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user