habitrpg-shared: bug fixes on hydrate()
This commit is contained in:
+5
-3
@@ -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
|
||||
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user