Permalink
Browse files

invoke callback if list of waiting matches returns an empty array

  • Loading branch information...
1 parent ef03c83 commit c43b0ab2084cb2b88d93ab6d355c85d8d70f157a @mkleine committed May 6, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 server/js-nodejs/src/main/js/core-foos-server.js
@@ -140,17 +140,17 @@ var startMatch = function (callback) {
getListOfMatches(function (docs) {
- if(!docs) {
- logger.warn("There's no match to start");
- callback();
- } else if (docs.length > 0) {
+ if (docs && docs.length > 0) {
var match = docs[0];
var date = new Date();
mongo.upsert(matches, {_id:match._id}, {state:MATCH_STATE_ACTIVE, startDate:date}, function () {
logger.log("Starting match: " + JSON.stringify(match));
match.startDate = date;
callback(match);
});
+ } else {
+ logger.warn("There's no match to start");
+ callback();
}
});

0 comments on commit c43b0ab

Please sign in to comment.