mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 03:52:14 +00:00
apiv2 fix to pending op (@litenull)
This commit is contained in:
parent
9e2ef95d84
commit
8760d07215
1 changed files with 4 additions and 1 deletions
|
|
@ -28,8 +28,9 @@ router.post '/', api.auth, (req, res, next) ->
|
|||
{user} = req
|
||||
actions = req.body
|
||||
|
||||
|
||||
doneCount = 1 + # cron
|
||||
actions.length # standard operations
|
||||
_.size(actions) # standard operations
|
||||
done = (err) ->
|
||||
return next(err) if err
|
||||
if --doneCount is 0
|
||||
|
|
@ -42,6 +43,8 @@ router.post '/', api.auth, (req, res, next) ->
|
|||
res.json 200, uObj
|
||||
console.log "Reply sent"
|
||||
|
||||
if _.isObject(actions) and _.isEmpty(actions) then done() # first request, empty object
|
||||
|
||||
misc.batchTxn model, (uObj, paths) ->
|
||||
# habitrpg-shared/algos requires uObj.habits, uObj.dailys etc instead of uObj.tasks
|
||||
_.each ['habit','daily','todo','reward'], (type) -> uObj["#{type}s"] = _.where(uObj.tasks, {type}); true
|
||||
|
|
|
|||
Loading…
Reference in a new issue