mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 19:06:59 -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) ->
|
loadFriends: (friendsCallback) ->
|
||||||
return friendsCallback() unless @loggedIn
|
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})
|
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()
|
@reauthorize()
|
||||||
@listenToOnce(@, 'logged-in', onReauthorized)
|
@listenToOnce(@, 'logged-in', onReauthorized)
|
||||||
else
|
else
|
||||||
|
|
|
@ -37,8 +37,11 @@ module.exports = class LevelSaveView extends SaveVersionModal
|
||||||
models = models.concat @lastContext.modifiedSystems
|
models = models.concat @lastContext.modifiedSystems
|
||||||
for changeEl, i in changeEls
|
for changeEl, i in changeEls
|
||||||
model = models[i]
|
model = models[i]
|
||||||
|
try
|
||||||
deltaView = new DeltaView({model:model})
|
deltaView = new DeltaView({model:model})
|
||||||
@insertSubView(deltaView, $(changeEl))
|
@insertSubView(deltaView, $(changeEl))
|
||||||
|
catch e
|
||||||
|
console.error "Couldn't create delta view:", e
|
||||||
|
|
||||||
shouldSaveEntity: (m) ->
|
shouldSaveEntity: (m) ->
|
||||||
return true if m.hasLocalChanges()
|
return true if m.hasLocalChanges()
|
||||||
|
|
|
@ -31,8 +31,11 @@ module.exports = class SaveVersionModal extends ModalView
|
||||||
super()
|
super()
|
||||||
@$el.find(if me.get('signedCLA') then '#accept-cla-wrapper' else '#save-version-button').hide()
|
@$el.find(if me.get('signedCLA') then '#accept-cla-wrapper' else '#save-version-button').hide()
|
||||||
changeEl = @$el.find('.changes-stub')
|
changeEl = @$el.find('.changes-stub')
|
||||||
|
try
|
||||||
deltaView = new DeltaView({model:@model})
|
deltaView = new DeltaView({model:@model})
|
||||||
@insertSubView(deltaView, changeEl)
|
@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'))
|
@$el.find('.commit-message input').attr('placeholder', $.i18n.t('general.commit_msg'))
|
||||||
|
|
||||||
onClickSaveButton: ->
|
onClickSaveButton: ->
|
||||||
|
|
|
@ -101,7 +101,7 @@ module.exports = class LadderTabView extends CocoView
|
||||||
|
|
||||||
gplusSessionStateLoaded: ->
|
gplusSessionStateLoaded: ->
|
||||||
if application.gplusHandler.loggedIn
|
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
|
application.gplusHandler.loadFriends @gplusFriendsLoaded
|
||||||
|
|
||||||
gplusFriendsLoaded: (friends) =>
|
gplusFriendsLoaded: (friends) =>
|
||||||
|
@ -205,8 +205,8 @@ module.exports = class LadderTabView extends CocoView
|
||||||
.attr("x",1)
|
.attr("x",1)
|
||||||
.attr("width",width/20)
|
.attr("width",width/20)
|
||||||
.attr("height", (d) -> height - y(d.y))
|
.attr("height", (d) -> height - y(d.y))
|
||||||
if @leaderboards[teamName].session?
|
if playerScore = @leaderboards[teamName].session?.get('totalScore')
|
||||||
playerScore = @leaderboards[teamName].session.get('totalScore') * 100
|
playerScore *= 100
|
||||||
scorebar = svg.selectAll(".specialbar")
|
scorebar = svg.selectAll(".specialbar")
|
||||||
.data([playerScore])
|
.data([playerScore])
|
||||||
.enter().append("g")
|
.enter().append("g")
|
||||||
|
|
|
@ -130,7 +130,7 @@ module.exports = class TomeView extends View
|
||||||
@thangSpells[thang.id].push spellKey
|
@thangSpells[thang.id].push spellKey
|
||||||
unless method.cloneOf
|
unless method.cloneOf
|
||||||
skipProtectAPI = @getQueryVariable "skip_protect_api", not @options.ladderGame
|
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
|
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
|
for thangID, spellKeys of @thangSpells
|
||||||
thang = world.getThangByID thangID
|
thang = world.getThangByID thangID
|
||||||
|
|
Loading…
Reference in a new issue