Skip to content

Commit

Permalink
😐 🔮 Add demo mode during outage
Browse files Browse the repository at this point in the history
  • Loading branch information
ishotjr committed Aug 1, 2016
1 parent 0db028e commit 6c41f88
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
23 changes: 21 additions & 2 deletions src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var gpsErrorReported = false;
var MessageQueue = require("./MessageQueue");
var DummyDataCreator = require("./dummyData");

var dummyData = DummyDataCreator.createDummyData(5, 45, -97);
var dummyData; // = DummyDataCreator.createDummyData(5, 45, -97);
console.log(JSON.stringify(dummyData));

var firstTimeUpdatingLocation = true;
Expand Down Expand Up @@ -71,7 +71,14 @@ function getPokemon() { //(latitude, longitude) {
// exclude throttling error (throttling error doesn't really matter since
// we can still view pokes from last scan...?)
if ((scanJson.status === "error") && (scanJson.message !== "{scan-throttle}")) {
MessageQueue.sendAppMessage({"DisplayMessage": "Server error"});

// advise of "demo mode" too if we're in it:
if (dummyData != null) {
MessageQueue.sendAppMessage({"DisplayMessage": "Server error" +
"\n\nPlease enjoy this DEMO using DUMMY DATA! :)"});
} else {
MessageQueue.sendAppMessage({"DisplayMessage": "Server error"});
}
serverError = true;
} else {
serverError = false;
Expand All @@ -82,6 +89,18 @@ function getPokemon() { //(latitude, longitude) {

xhrRequest(dataUrl, 'GET', function(dataResponseText) {
var json = JSON.parse(dataResponseText);

// TODO: this is silly - really should just not do xhrRequest at all, but
// as a quick hack to enable "demo mode" for now...
if (serverError) {
// populate if not set (once)
if (dummyData == null) {
dummyData = DummyDataCreator.createDummyData(5, myLatitude, myLongitude);
}
json = dummyData;
}


console.log(dataResponseText); // JSON.stringify() not necessary!

// TODO: status check!
Expand Down
8 changes: 6 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ void config(void *context){
static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {

// call API on the 15s (for now until distance refresh implemented)
if (tick_time->tm_sec % 15 == 0) {
//if (tick_time->tm_sec % 15 == 0) {
// TODO: restore temporary decrease in frequency when demo mode is no longer nec.
if (tick_time->tm_sec % 30 == 0) {

APP_LOG(APP_LOG_LEVEL_INFO, "tick_handler() 0/15/30/45");

Expand Down Expand Up @@ -199,7 +201,9 @@ void displayToast(char *string) {
vibes_double_pulse();

animate_layer(alert, &from_frame, &to_frame, 1000, 0);
animate_layer(alert, &to_frame, &from_frame, 1000, 3000);
//animate_layer(alert, &to_frame, &from_frame, 1000, 3000);
// TODO: remove temporary increase when demo mode is no longer nec.
animate_layer(alert, &to_frame, &from_frame, 1000, 5000);
}

static void bluetooth_callback(bool connected) {
Expand Down

0 comments on commit 6c41f88

Please sign in to comment.