mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 20:12:19 +00:00
bug fixes: don't allow dotSet/Get on undefined paths, remove @hydrate
from derbyUserToAPI()
This commit is contained in:
parent
6b56067668
commit
cafcde01ec
1 changed files with 5 additions and 2 deletions
|
|
@ -112,6 +112,7 @@ module.exports =
|
|||
Angular sets object properties directly - in which case, this function will be used.
|
||||
###
|
||||
dotSet: (path, val, obj) ->
|
||||
return if ~path.indexOf('undefined')
|
||||
arr = path.split('.')
|
||||
_.reduce arr, (curr, next, index) ->
|
||||
if (arr.length - 1) == index
|
||||
|
|
@ -119,7 +120,9 @@ module.exports =
|
|||
curr[next]
|
||||
, obj
|
||||
|
||||
dotGet: (path, obj) -> _.reduce path.split('.'), ((curr, next) -> curr[next]), obj
|
||||
dotGet: (path, obj) ->
|
||||
return undefined if ~path.indexOf('undefined')
|
||||
_.reduce path.split('.'), ((curr, next) -> curr[next]), obj
|
||||
|
||||
daysBetween: daysBetween
|
||||
|
||||
|
|
@ -361,7 +364,7 @@ module.exports =
|
|||
local ops, because the var-by-reference lets us edit the original tasks
|
||||
###
|
||||
derbyUserToAPI: (userScope, keepTasks=true) ->
|
||||
uObj = @hydrate userScope.get()
|
||||
uObj = userScope.get()
|
||||
_.each ['habit','daily','todo','reward'], (type) ->
|
||||
# we use _.transform instead of a simple _.where in order to maintain sort-order
|
||||
uObj["#{type}s"] = _.transform uObj["#{type}Ids"], (result, tid) -> result.push(uObj.tasks[tid])
|
||||
|
|
|
|||
Loading…
Reference in a new issue