From 77e37804e86c19c21e94ce47448377bbb3d95c1e Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Wed, 22 May 2013 13:57:10 +0100 Subject: [PATCH] habitrpg-shared: bug fixes on hydrate() --- src/app/misc.coffee | 8 +++++--- src/app/tasks.coffee | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/misc.coffee b/src/app/misc.coffee index f0d72af8b1..199f7ce845 100644 --- a/src/app/misc.coffee +++ b/src/app/misc.coffee @@ -6,9 +6,11 @@ helpers = require('habitrpg-shared/script/helpers') ### Make sure model.get() returns all properties, see https://github.com/codeparty/racer/issues/116 ### -module.exports.hydrate = hydrate = (spec, hydrated={}) -> - if _.isPlainObject(spec) - hydrated[k] = hydrate(v, hydrated[k]) for k,v of spec +module.exports.hydrate = hydrate = (spec) -> + if _.isObject(spec) and !_.isArray(spec) + hydrated = {} + keys = _.keys(spec).concat(_.keys(spec.__proto__)) + keys.forEach (k) -> hydrated[k] = hydrate(spec[k]) hydrated else spec diff --git a/src/app/tasks.coffee b/src/app/tasks.coffee index 65f76177a2..689f47b571 100644 --- a/src/app/tasks.coffee +++ b/src/app/tasks.coffee @@ -19,7 +19,7 @@ module.exports.app = (appExports, model) -> perform the updates while tracking paths, then all the values at those paths ### score = (taskId, direction) -> -# return setTimeout( (-> score(taskId, direction)), 500) if model._txnQueue.length > 0 + #return setTimeout( (-> score(taskId, direction)), 500) if model._txnQueue.length > 0 uObj = misc.hydrate(user.get()) # see https://github.com/codeparty/racer/issues/116 tObj = uObj.tasks[taskId]