mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 01:55:38 -05:00
A bit of error handling.
This commit is contained in:
parent
0ce04b147d
commit
a9725f2dc6
6 changed files with 52 additions and 45 deletions
|
@ -107,9 +107,10 @@ module.exports = GPlusHandler = class GPlusHandler extends CocoClass
|
|||
|
||||
loadFriends: (friendsCallback) ->
|
||||
return friendsCallback() unless @loggedIn
|
||||
expires_in = if @accessToken then parseInt(@accessToken.expires_at) - new Date().getTime()/1000 else -1
|
||||
expiresIn = if @accessToken then parseInt(@accessToken.expires_at) - new Date().getTime()/1000 else -1
|
||||
onReauthorized = => gapi.client.request({path:'/plus/v1/people/me/people/visible', callback: friendsCallback})
|
||||
if expires_in < 0
|
||||
if expiresIn < 0
|
||||
# TODO: this tries to open a popup window, which might not ever finish or work, so the callback may never be called.
|
||||
@reauthorize()
|
||||
@listenToOnce(@, 'logged-in', onReauthorized)
|
||||
else
|
||||
|
|
|
@ -37,8 +37,11 @@ module.exports = class LevelSaveView extends SaveVersionModal
|
|||
models = models.concat @lastContext.modifiedSystems
|
||||
for changeEl, i in changeEls
|
||||
model = models[i]
|
||||
deltaView = new DeltaView({model:model})
|
||||
@insertSubView(deltaView, $(changeEl))
|
||||
try
|
||||
deltaView = new DeltaView({model:model})
|
||||
@insertSubView(deltaView, $(changeEl))
|
||||
catch e
|
||||
console.error "Couldn't create delta view:", e
|
||||
|
||||
shouldSaveEntity: (m) ->
|
||||
return true if m.hasLocalChanges()
|
||||
|
|
|
@ -31,8 +31,11 @@ module.exports = class SaveVersionModal extends ModalView
|
|||
super()
|
||||
@$el.find(if me.get('signedCLA') then '#accept-cla-wrapper' else '#save-version-button').hide()
|
||||
changeEl = @$el.find('.changes-stub')
|
||||
deltaView = new DeltaView({model:@model})
|
||||
@insertSubView(deltaView, changeEl)
|
||||
try
|
||||
deltaView = new DeltaView({model:@model})
|
||||
@insertSubView(deltaView, changeEl)
|
||||
catch e
|
||||
console.error "Couldn't create delta view:", e
|
||||
@$el.find('.commit-message input').attr('placeholder', $.i18n.t('general.commit_msg'))
|
||||
|
||||
onClickSaveButton: ->
|
||||
|
|
|
@ -101,7 +101,7 @@ module.exports = class LadderTabView extends CocoView
|
|||
|
||||
gplusSessionStateLoaded: ->
|
||||
if application.gplusHandler.loggedIn
|
||||
@addSomethingToLoad("gplus_friends")
|
||||
@addSomethingToLoad("gplus_friends", 0) # this might not load ever, so we can't wait for it
|
||||
application.gplusHandler.loadFriends @gplusFriendsLoaded
|
||||
|
||||
gplusFriendsLoaded: (friends) =>
|
||||
|
@ -205,8 +205,8 @@ module.exports = class LadderTabView extends CocoView
|
|||
.attr("x",1)
|
||||
.attr("width",width/20)
|
||||
.attr("height", (d) -> height - y(d.y))
|
||||
if @leaderboards[teamName].session?
|
||||
playerScore = @leaderboards[teamName].session.get('totalScore') * 100
|
||||
if playerScore = @leaderboards[teamName].session?.get('totalScore')
|
||||
playerScore *= 100
|
||||
scorebar = svg.selectAll(".specialbar")
|
||||
.data([playerScore])
|
||||
.enter().append("g")
|
||||
|
|
|
@ -130,7 +130,7 @@ module.exports = class TomeView extends View
|
|||
@thangSpells[thang.id].push spellKey
|
||||
unless method.cloneOf
|
||||
skipProtectAPI = @getQueryVariable "skip_protect_api", not @options.ladderGame
|
||||
skipFlow = @getQueryVariable "skip_flow", @options.levelID is 'brawlwood'
|
||||
skipFlow = @getQueryVariable "skip_flow", @options.levelID is 'brawlwood' or @options.levelID is 'resource-gathering-multiplayer'
|
||||
spell = @spells[spellKey] = new Spell programmableMethod: method, spellKey: spellKey, pathComponents: pathPrefixComponents.concat(pathComponents), session: @options.session, supermodel: @supermodel, skipFlow: skipFlow, skipProtectAPI: skipProtectAPI, worker: @worker
|
||||
for thangID, spellKeys of @thangSpells
|
||||
thang = world.getThangByID thangID
|
||||
|
|
Loading…
Reference in a new issue