Skip to content

Commit

Permalink
Don't figure out next venues until somebody has logged in. Save past …
Browse files Browse the repository at this point in the history
…user locations.
  • Loading branch information
Tony Salomone committed Apr 11, 2011
1 parent ac4136d commit 57fe1ae
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions server/server.js
Expand Up @@ -6,7 +6,7 @@ var NUM_NEXT_VENUE_OPTIONS = 5;

// init data
var currentVenue;
var nextVenues;
var nextVenues = null;

// set the starting point to PostRank
currentVenue = {
Expand Down Expand Up @@ -58,6 +58,12 @@ var everyone = require("now").initialize(app);

everyone.connected(function(){
console.log("Joined: " + this.now.name);

// if this is the first person to log in then initialize the data!
if (nextVenues == null) {
getNextVenues(currentVenue);
}

everyone.now.setCurrentLocation(currentVenue);
everyone.now.setNextVenues(nextVenues);
});
Expand Down Expand Up @@ -97,6 +103,12 @@ everyone.now.doToppl = function() {
if (newVenue >= 0) {
currentVenue = nextVenues[newVenue];
everyone.now.setCurrentLocation(currentVenue);
locations[currentVenue.name] = {
coords: {
longitude : currentVenue.geoCode.longitude,
latitude : currentVenue.geoCode.latitude
}
};
console.log("TOPPL! New venue is " + currentVenue.name);

getNextVenues(currentVenue);
Expand Down Expand Up @@ -160,4 +172,3 @@ function getNextVenues(currentVenue) {
});
}

getNextVenues(currentVenue);

0 comments on commit 57fe1ae

Please sign in to comment.