mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 03:52:14 +00:00
Merge branch 'master' of github.com:lefnire/habitrpg into middleware
This commit is contained in:
commit
484b043ec8
6 changed files with 23 additions and 25 deletions
|
|
@ -23,7 +23,8 @@
|
|||
"mongoskin": "*",
|
||||
"nconf": "*",
|
||||
"icalendar": "git://github.com/lefnire/node-icalendar#master",
|
||||
"nodetime": "*"
|
||||
"nodetime": "*",
|
||||
"resolve": "~0.2.3"
|
||||
},
|
||||
"private": true,
|
||||
"subdomain": "habitrpg",
|
||||
|
|
|
|||
|
|
@ -45,16 +45,15 @@ loadJavaScripts = (model) ->
|
|||
require '../../public/vendor/jquery-ui/ui/jquery.ui.core'
|
||||
require '../../public/vendor/jquery-ui/ui/jquery.ui.widget'
|
||||
require '../../public/vendor/jquery-ui/ui/jquery.ui.mouse'
|
||||
require '../../public/vendor/jquery-ui/ui/jquery.ui.draggable'
|
||||
require '../../public/vendor/jquery-ui/ui/jquery.ui.position'
|
||||
require '../../public/vendor/jquery-ui/ui/jquery.ui.sortable'
|
||||
|
||||
# Bootstrap
|
||||
require '../../public/vendor/bootstrap/js/bootstrap-tooltip'
|
||||
require '../../public/vendor/bootstrap/js/bootstrap-tab'
|
||||
require '../../public/vendor/bootstrap/js/bootstrap-popover'
|
||||
require '../../public/vendor/bootstrap/js/bootstrap-modal'
|
||||
require '../../public/vendor/bootstrap/js/bootstrap-dropdown'
|
||||
require '../../public/vendor/bootstrap/docs/assets/js/bootstrap'
|
||||
# require '../../public/vendor/bootstrap/js/bootstrap-tooltip'
|
||||
# require '../../public/vendor/bootstrap/js/bootstrap-tab'
|
||||
# require '../../public/vendor/bootstrap/js/bootstrap-popover'
|
||||
# require '../../public/vendor/bootstrap/js/bootstrap-modal'
|
||||
# require '../../public/vendor/bootstrap/js/bootstrap-dropdown'
|
||||
|
||||
|
||||
require '../../public/vendor/jquery-cookie/jquery.cookie'
|
||||
|
|
|
|||
|
|
@ -179,20 +179,14 @@ module.exports.BatchUpdate = BatchUpdate = (model) ->
|
|||
user: user
|
||||
|
||||
obj: ->
|
||||
obj ?= model.get('users.'+user.get('id'), true)
|
||||
obj ?= model.get 'users.'+user.get('id')
|
||||
return obj
|
||||
|
||||
startTransaction: ->
|
||||
# start a batch transaction - nothing between now and @commit() will be set immediately
|
||||
transactionInProgress = true
|
||||
model._dontPersist = true
|
||||
|
||||
# Really strange, user.get() seems to only return attributes which have previously been accessed. So in
|
||||
# many cases, userObj.tasks.{taskId}.value is undefined - so we manually .get() each attribute here.
|
||||
# Additionally, for some reason after getting the user object, changing properies manually (userObj.stats.hp = 50)
|
||||
# seems to actually run user.set('stats.hp',50) which we don't want to do - so we deepClone here
|
||||
#_.each Object.keys(userSchema), (key) -> obj[key] = lodash.cloneDeep user.get(key)
|
||||
obj = @obj()
|
||||
@obj()
|
||||
|
||||
###
|
||||
Handles updating the user model. If this is an en-mass operation (eg, server cron), changes are queued
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ ready (model) ->
|
|||
|
||||
scoring.cron()
|
||||
|
||||
browser.app(exports, model)
|
||||
character.app(exports, model)
|
||||
tasks.app(exports, model)
|
||||
items.app(exports, model)
|
||||
|
|
@ -59,4 +58,5 @@ ready (model) ->
|
|||
profile.app(exports, model)
|
||||
require('../server/private').app(exports, model)
|
||||
require('./debug').app(exports, model) if model.get('_view.nodeEnv') != 'production'
|
||||
browser.app(exports, model)
|
||||
|
||||
|
|
|
|||
|
|
@ -27,19 +27,23 @@ module.exports.partySubscribe = partySubscribe = (model, cb) ->
|
|||
|
||||
# Restart subscription to the main user
|
||||
selfQ = model.query('users').withId(model.get('_userId') or model.session.userId)
|
||||
selfQ.fetch (err, res) ->
|
||||
selfQ.subscribe (err, self) ->
|
||||
throw err if err
|
||||
u = res.at(0)
|
||||
u = self.at(0)
|
||||
uObj = u.get()
|
||||
|
||||
finished = ->
|
||||
selfQ.subscribe (err, res) ->
|
||||
model.ref '_user', res.at(0)
|
||||
browser.resetDom(model) if window?
|
||||
cb() if cb?
|
||||
model.unsubscribe selfQ, ->
|
||||
selfQ.subscribe (err, self) ->
|
||||
model.ref '_user', self.at(0)
|
||||
browser.resetDom(model) if window?
|
||||
cb() if cb?
|
||||
|
||||
## (1) User is solo, just return that subscription
|
||||
return finished() unless uObj.party?.current
|
||||
unless uObj.party?.current
|
||||
model.ref '_user', u
|
||||
browser.resetDom(model) if window?
|
||||
return if cb then cb() else null
|
||||
|
||||
|
||||
# User in a party
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ cron = () ->
|
|||
batch.setStats()
|
||||
batch.set('history', obj.history)
|
||||
batch.commit()
|
||||
#browser.resetDom(model)
|
||||
browser.resetDom(model)
|
||||
setTimeout (-> user.set 'stats.hp', hpAfter), 1000 # animate hp loss
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue