Skip to content

Commit

Permalink
Fix race condition in CampaignView
Browse files Browse the repository at this point in the history
Sometimes, the poll request will return 404, and when that happens
the view stops listening to the supermodel and it never really 'loads',
and looks as if the user did not have any sessions. Changed the
'stop listening' behavior to only happen for blocking requests, ie
ones with value greater than 0.
  • Loading branch information
sderickson committed Mar 20, 2018
1 parent 41124f9 commit 9014246
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/views/core/CocoView.coffee
Expand Up @@ -229,7 +229,8 @@ module.exports = class CocoView extends Backbone.View
# Error handling for loading
onResourceLoadFailed: (e) ->
r = e.resource
@stopListening @supermodel
if r.value
@stopListening @supermodel
return if r.jqxhr?.status is 402 # payment-required failures are handled separately
@showError(r.jqxhr)

Expand Down
2 changes: 1 addition & 1 deletion app/views/play/CampaignView.coffee
Expand Up @@ -152,7 +152,7 @@ module.exports = class CampaignView extends RootView
@supermodel.addRequestResource(url: '/picoctf/problems', success: (@picoCTFProblems) =>).load()
else
unless @editorMode
@sessions = @supermodel.loadCollection(new LevelSessionsCollection(), 'your_sessions', {cache: false}, 0).model
@sessions = @supermodel.loadCollection(new LevelSessionsCollection(), 'your_sessions', {cache: false}, 1).model
@listenToOnce @sessions, 'sync', @onSessionsLoaded
unless @terrain
@campaigns = @supermodel.loadCollection(new CampaignsCollection(), 'campaigns', null, 1).model
Expand Down

0 comments on commit 9014246

Please sign in to comment.