Trigger storage of latest level only after the level is guaranteed to be able to load

This commit is contained in:
Tay Yang Shun 2014-02-27 14:08:25 +08:00
parent bb76fb241c
commit 514fe358c1

View file

@ -92,10 +92,6 @@ module.exports = class PlayLevelView extends View
else
@load()
# Save latest level played in local storage
if localStorage?
localStorage["lastLevel"] = @levelID
onLevelLoadError: (e) =>
application.router.navigate "/play?not_found=#{@levelID}", {trigger: true}
@ -129,6 +125,10 @@ module.exports = class PlayLevelView extends View
super()
onLevelLoaderLoaded: =>
# Save latest level played in local storage
if localStorage?
localStorage["lastLevel"] = @levelID
@session = @levelLoader.session
@world = @levelLoader.world
@level = @levelLoader.level