mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-13 22:49:51 -04:00
Don't throw away fully loaded supermodels in between simulations or refresh tabs when not looking at them.
This commit is contained in:
parent
a58faa1acd
commit
4355813d69
3 changed files with 13 additions and 6 deletions
|
@ -107,6 +107,7 @@ module.exports = class LevelLoader extends CocoClass
|
|||
# Things to do when either the Session or Supermodel load
|
||||
|
||||
update: =>
|
||||
return if @destroyed
|
||||
@notifyProgress()
|
||||
|
||||
return if @updateCompleted
|
||||
|
|
|
@ -44,7 +44,7 @@ module.exports = class Simulator extends CocoClass
|
|||
return @handleNoGamesResponse() if jqXHR.status is 204
|
||||
@trigger 'statusUpdate', 'Setting up simulation!'
|
||||
@task = new SimulationTask(taskData)
|
||||
@supermodel = new SuperModel()
|
||||
@supermodel ?= new SuperModel()
|
||||
@god = new God maxWorkerPoolSize: 1, maxAngels: 1 # Start loading worker.
|
||||
|
||||
@levelLoader = new LevelLoader supermodel: @supermodel, levelID: @task.getLevelName(), sessionID: @task.getFirstSessionID(), headless: true
|
||||
|
|
|
@ -75,11 +75,17 @@ module.exports = class LadderView extends RootView
|
|||
@sessions.fetch({"success": @refreshViews})
|
||||
|
||||
refreshViews: =>
|
||||
return if @destroyed or application.userIsIdle or new Date() - 2000 < @lastRefreshTime
|
||||
@lastRefreshTime = new Date()
|
||||
@ladderTab.refreshLadder()
|
||||
@myMatchesTab.refreshMatches()
|
||||
console.log "Refreshing ladder and matches views."
|
||||
return if @destroyed or application.userIsIdle
|
||||
if @$el.find("#ladder.active").length
|
||||
return if new Date() - 2000 < @lastLadderRefreshTime
|
||||
@lastLadderRefreshTime = new Date()
|
||||
@ladderTab.refreshLadder()
|
||||
console.log "Refreshing ladder."
|
||||
if @$el.find("#my-matches.active").length
|
||||
return if new Date() - 2000 < @lastMatchesRefreshTime
|
||||
@lastMatchesRefreshTime = new Date()
|
||||
@myMatchesTab.refreshMatches()
|
||||
console.log "Refreshing matches view."
|
||||
|
||||
onIdleChanged: (e) ->
|
||||
@refreshViews() unless e.idle
|
||||
|
|
Loading…
Reference in a new issue