mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-02 04:00:36 +00:00
don't show drop notification unless it went through to the database.
oohhh this is glorious!! @Shaners @Slappybag @lemoness , you're gonna love this one.
This commit is contained in:
parent
ef39dd8a0f
commit
a4de2e5ec5
1 changed files with 7 additions and 4 deletions
|
|
@ -18,7 +18,7 @@ module.exports.batchTxn = batchTxn = (model, cb, options) ->
|
|||
# pass true if we have levelled to supress xp notification
|
||||
unless _.isEmpty paths
|
||||
setOps = _.reduce paths, ((m,v,k)-> m[k] = helpers.dotGet(k,uObj);m), {}
|
||||
user.set "update__", setOps
|
||||
user.set "update__", setOps, options?.done
|
||||
ret
|
||||
|
||||
#TODO put this in habitrpg-shared
|
||||
|
|
@ -44,6 +44,7 @@ taskInChallenge = (task) ->
|
|||
perform the updates while tracking paths, then all the values at those paths
|
||||
###
|
||||
module.exports.score = (model, taskId, direction, allowUndo=false) ->
|
||||
drop = undefined
|
||||
delta = batchTxn model, (uObj, paths) ->
|
||||
tObj = uObj.tasks[taskId]
|
||||
|
||||
|
|
@ -58,9 +59,7 @@ module.exports.score = (model, taskId, direction, allowUndo=false) ->
|
|||
|
||||
delta = algos.score(uObj, tObj, direction, {paths})
|
||||
model.set('_streakBonus', uObj._tmp.streakBonus) if uObj._tmp?.streakBonus
|
||||
if uObj._tmp?.drop and $?
|
||||
model.set '_drop', uObj._tmp.drop
|
||||
$('#item-dropped-modal').modal 'show'
|
||||
drop = uObj._tmp?.drop
|
||||
|
||||
# Update challenge statistics
|
||||
# FIXME put this in it's own batchTxn, make batchTxn model.at() ref aware (not just _user)
|
||||
|
|
@ -80,6 +79,10 @@ module.exports.score = (model, taskId, direction, allowUndo=false) ->
|
|||
value: tObj.value
|
||||
history: tObj.history
|
||||
model._dontPersist = true
|
||||
, done:->
|
||||
if drop and $?
|
||||
model.set '_drop', drop
|
||||
$('#item-dropped-modal').modal 'show'
|
||||
|
||||
delta
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue