From e3bf8f74ab4bb0f43ddd035babcec93cc4b56596 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Thu, 22 Jan 2015 12:26:37 -0800 Subject: [PATCH] Trying to stagger LevelSessions saves on wins on replayable levels to see if that might help #2108 at all. --- app/models/LevelSession.coffee | 4 ++-- app/views/play/level/PlayLevelView.coffee | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/models/LevelSession.coffee b/app/models/LevelSession.coffee index bf40073ea..3e2732eb2 100644 --- a/app/models/LevelSession.coffee +++ b/app/models/LevelSession.coffee @@ -54,13 +54,13 @@ module.exports = class LevelSession extends CocoModel return if @shouldAvoidCorruptData attrs super attrs, options - increaseDifficulty: -> + increaseDifficulty: (callback) -> state = @get('state') ? {} state.difficulty = (state.difficulty ? 0) + 1 delete state.lastUnsuccessfulSubmissionTime @set 'state', state - @save() @trigger 'change-difficulty' + @save null, success: callback timeUntilResubmit: -> state = @get('state') ? {} diff --git a/app/views/play/level/PlayLevelView.coffee b/app/views/play/level/PlayLevelView.coffee index fd16c3caf..dcb21d8e5 100644 --- a/app/views/play/level/PlayLevelView.coffee +++ b/app/views/play/level/PlayLevelView.coffee @@ -523,8 +523,11 @@ module.exports = class PlayLevelView extends RootView return if @destroyed # TODO: Show a victory dialog specific to hero-ladder level if @goalManager.checkOverallStatus() is 'success' and not @options.realTimeMultiplayerSessionID? - @session.increaseDifficulty() if @level.get 'replayable' - Backbone.Mediator.publish 'level:show-victory', showModal: true + showModalFn = -> Backbone.Mediator.publish 'level:show-victory', showModal: true + if @level.get 'replayable' + @session.increaseDifficulty showModalFn + else + showModalFn() destroy: -> @levelLoader?.destroy()