Fix: Some level systems load forever.

This commit is contained in:
Ting-Kuan 2014-04-19 12:08:40 -04:00
parent 692693c181
commit 375aca2c0a
4 changed files with 15 additions and 15 deletions

View file

@ -11,6 +11,14 @@ module.exports = class SuperModel extends Backbone.Model
@collections = {}
@schemas = {}
# setInterval(@checkModelStatus, 5000)
# For debugging
checkModelStatus: =>
for key, res of @resources
continue if res.isLoaded
console.debug 'resource ' + res.name + ' is still loading'
populateModel: (model, resName) ->
@mustPopulate = model
model.saveBackups = @shouldSaveBackups(model)
@ -222,15 +230,6 @@ class ModelResource extends Resource
fetchModel: ->
@model.fetch(@fetchOptions)
###
setTimeout(=>
if @isLoading
@markLoaded()
@loadDeferred.resolve(@)
console.debug 'gintau', 'load-timeout'
, 5000)
###
@listenToOnce(@model, 'sync', ->
@markLoaded()

View file

@ -14,7 +14,7 @@ module.exports = class JobProfileView extends CocoView
afterRender: ->
super()
return if @loading()
return unless @supermodel.finished()
_.defer => @buildJobProfileTreema() # Not sure why, but the Treemas don't fully build without this if you reload the page.
buildJobProfileTreema: ->

View file

@ -33,9 +33,10 @@ module.exports = class SystemsTabView extends View
ls = new LevelSystem()
ls.saveBackups = true
lsRes = @supermodel.addModelResource(ls, 'level_system_' + system.original)
lsRes.load()
do (url) -> ls.url = -> url
continue if @supermodel.getModelByURL ls.url
lsRes.load()
@listenToOnce(lsRes, 'resource:loaded', @onSystemLoaded)
++@toLoad
@onDefaultSystemsLoaded() unless @toLoad

View file

@ -36,7 +36,7 @@ module.exports = class LadderTabView extends CocoView
constructor: (options, @level, @sessions) ->
super(options)
@socialNetworkRes = @supermodel.addSomethingResource("social_network_apis")
@socialNetworkRes = @supermodel.addSomethingResource("social_network_apis", 0)
@teams = teamDataFromLevel @level
@leaderboards = {}
@ -49,7 +49,7 @@ module.exports = class LadderTabView extends CocoView
# @addSomethingToLoad("facebook_status")
@fbStatusRes = @supermodel.addSomethingResource("facebook_status")
@fbStatusRes = @supermodel.addSomethingResource("facebook_status", 0)
@fbStatusRes.load()
FB.getLoginStatus (response) =>
@ -75,7 +75,7 @@ module.exports = class LadderTabView extends CocoView
loadFacebookFriends: ->
# @addSomethingToLoad("facebook_friends")
@fbFriendRes = @supermodel.addSomethingResource("facebook_friends")
@fbFriendRes = @supermodel.addSomethingResource("facebook_friends", 0)
@fbFriendRes.load()
FB.api '/me/friends', @onFacebookFriendsLoaded
@ -128,7 +128,7 @@ module.exports = class LadderTabView extends CocoView
gplusSessionStateLoaded: ->
if application.gplusHandler.loggedIn
#@addSomethingToLoad("gplus_friends")
@gpFriendRes = @supermodel.addSomethingResource("gplus_friends")
@gpFriendRes = @supermodel.addSomethingResource("gplus_friends", 0)
@gpFriendRes.load()
application.gplusHandler.loadFriends @gplusFriendsLoaded