diff --git a/app/lib/LevelSetupManager.coffee b/app/lib/LevelSetupManager.coffee index e5acfdbd1..9e40444a1 100644 --- a/app/lib/LevelSetupManager.coffee +++ b/app/lib/LevelSetupManager.coffee @@ -28,24 +28,24 @@ module.exports = class LevelSetupManager extends CocoClass @level = @supermodel.loadModel(@level, 'level').model if @level.loaded then @onLevelSync() else @listenToOnce @level, 'sync', @onLevelSync + loadSession: -> + sessionURL = "/db/level/#{@options.levelID}/session" + #sessionURL += "?team=#{@team}" if @options.team # TODO: figure out how to get the teams for multiplayer PVP hero style + sessionURL += "?course=#{@options.courseID}" if @options.courseID + @session = new LevelSession().setURL sessionURL + @session = @supermodel.loadModel(@session, 'level_session').model + if @session.loaded then @onSessionSync() else @listenToOnce @session, 'sync', @onSessionSync + onLevelSync: -> return if @destroyed if @waitingToLoadModals @waitingToLoadModals = false @loadModals() - loadSession: -> - sessionURL = "/db/level/#{@options.levelID}/session" - #sessionURL += "?team=#{@team}" if @options.team # TODO: figure out how to get the teams for multiplayer PVP hero style - sessionURL += "?course=#{@options.courseID}" if @options.courseID - @session = new LevelSession().setURL sessionURL - onSessionSync = -> - return if @destroyed - @session.url = -> '/db/level.session/' + @id - @fillSessionWithDefaults() - @listenToOnce @session, 'sync', onSessionSync - @session = @supermodel.loadModel(@session, 'level_session').model - onSessionSync.call @ if @session.loaded + onSessionSync: -> + return if @destroyed + @session.url = -> '/db/level.session/' + @id + @fillSessionWithDefaults() fillSessionWithDefaults: -> heroConfig = _.merge {}, me.get('heroConfig'), @session.get('heroConfig')