Skip to content

Commit

Permalink
When a game is recorded, put it in correct sort order.
Browse files Browse the repository at this point in the history
  • Loading branch information
derikson committed Sep 2, 2014
1 parent bc249f2 commit 24ac447
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/js/controllers/recordController.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ var RecordController = function($scope, GameService, FactionService) {
}
}

function sortGames(games) {
return games.sort(function(a, b) { return a.date < b.date ? 1 : a.date > b.date ? -1 : 0 });
}

$scope.isResultLoss = function(resultString) {
for(var i = 0; i < $scope.results.length; i ++) {
if ($scope.results[i].name === resultString) {
Expand Down Expand Up @@ -110,7 +114,8 @@ var RecordController = function($scope, GameService, FactionService) {
teaching: Boolean(results[2]),
};
GameService.submitGame(game);
$scope.games.unshift(game);
$scope.games.push(game);
$scope.games = sortGames($scope.games);
resetValues();
};

Expand Down

0 comments on commit 24ac447

Please sign in to comment.