Merge pull request from duybkict/refactor-MainLadderView

refactor MainLadderView
This commit is contained in:
Scott Erickson 2016-06-02 10:08:20 -07:00
commit bd64764b6c

View file

@ -15,15 +15,16 @@ module.exports = class MainLadderView extends RootView
id: 'main-ladder-view'
template: template
constructor: (options) ->
super options
@levelStatusMap = {}
@levelPlayCountMap = {}
@sessions = @supermodel.loadCollection(new LevelSessionsCollection(), 'your_sessions', {cache: false}, 0).model
@listenToOnce @sessions, 'sync', @onSessionsLoaded
@getLevelPlayCounts()
initialize: ->
@levelStatusMap = []
@levelPlayCountMap = []
@campaigns = campaigns
@sessions = @supermodel.loadCollection(new LevelSessionsCollection(), 'your_sessions', {cache: false}, 0).model
@listenToOnce @sessions, 'sync', @onSessionsLoaded
@getLevelPlayCounts()
onSessionsLoaded: (e) ->
for session in @sessions.models
@levelStatusMap[session.get('levelID')] = if session.get('state')?.complete then 'complete' else 'started'