Skip to content

Commit

Permalink
Avoid running tryStartingGame again if we're already in the process o…
Browse files Browse the repository at this point in the history
…f launching the game

This can happen if, for example, you hit enter more than once while logging in. The only visible impact seemed to be that they play button text (either "Login" or "Create") did not get restored properly (it stayed as "Loading"), but this has potential to cause other problems as well, and should be fixed.
  • Loading branch information
Sergey Krilov committed Sep 21, 2013
1 parent fc2368f commit 7537e98
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions client/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ define(['jquery', 'storage'], function($, Storage) {
},

tryStartingGame: function() {
if(this.starting) return; // Already loading

var self = this;
var action = this.createNewCharacterFormActive() ? 'create' : 'login';
var username = this.getUsernameField().attr('value');
Expand Down Expand Up @@ -170,13 +172,15 @@ define(['jquery', 'storage'], function($, Storage) {
var $playButton = this.getPlayButton();

if(enabled) {
this.starting = false;
this.$play.removeClass('loading');
$playButton.click(function () { self.tryStartingGame(); });
if(this.playButtonRestoreText) {
$playButton.text(this.playButtonRestoreText);
}
} else {
// Loading state
this.starting = true;
this.$play.addClass('loading');
$playButton.unbind('click');
this.playButtonRestoreText = $playButton.text();
Expand Down

0 comments on commit 7537e98

Please sign in to comment.