diff options
author | bahbka <bahbka@gmail.com> | 2014-07-28 12:11:04 +0400 |
---|---|---|
committer | bahbka <bahbka@gmail.com> | 2014-07-28 12:11:04 +0400 |
commit | ed4137837ae63c8fca781b6233eed34655fab724 (patch) | |
tree | 8f396a46e92ddc428152850bb3808d8accdb7bda | |
parent | ec266c45a64ecaf5d527771a618ac0b079a50edb (diff) |
Workaround for APP_MSG_INTERNAL_ERROR.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | appinfo.json | 4 | ||||
-rw-r--r-- | resources/configuration.html | 2 | ||||
-rw-r--r-- | src/js/pebble-js-app.src.js | 42 | ||||
-rw-r--r-- | src/pebble-my-data.c | 6 | ||||
-rw-r--r-- | stuff/pebble-my-data.pbw | bin | 32405 -> 32372 bytes |
7 files changed, 36 insertions, 23 deletions
@@ -14,5 +14,5 @@ build/pebble-my-data.pbw: src/js/pebble-js-app.js src/pebble-my-data.c appinfo.j pebble build src/js/pebble-js-app.js: src/js/pebble-js-app.src.js resources/configuration.html - perl -pe 'BEGIN { local $$/; open $$fh,pop @ARGV or die $$!; $$f = <$$fh>; $$f =~ s/\047/\\\047/g; } s/_HTMLMARKER_/$$f/g;' $^ | uglifyjs > $@ + perl -pe 'BEGIN { local $$/; open $$fh,pop @ARGV or die $$!; $$f = <$$fh>; $$f =~ s/\047/\\\047/g; $$f =~ s/\n//g; } s/_HTMLMARKER_/$$f/g;' $^ | uglifyjs > $@ @@ -32,6 +32,9 @@ Inspired by [Pebble Cards](http://keanulee.com/pebblecards). ## Changelog +### 2.3.4 +- Workaround for APP_MSG_INTERNAL_ERROR (request last response after 0.1s if occur) + ### 2.3.3 - Extract fields from any level of JSON (useful with [KimonoLabs API](https://www.kimonolabs.com)); multiple content fields will be concatenated with '\n\n'; other fields will be converted to integer, first copy will be used - Don't schedule update if another one already in progress diff --git a/appinfo.json b/appinfo.json index 0e7eed2..01d9b1e 100644 --- a/appinfo.json +++ b/appinfo.json @@ -3,8 +3,8 @@ "shortName": "My Data", "longName": "My Data", "companyName": "bahbka", - "versionCode": 233, - "versionLabel": "2.3.3", + "versionCode": 234, + "versionLabel": "2.3.4", "watchapp": { "watchface": false }, diff --git a/resources/configuration.html b/resources/configuration.html index 6adb9bb..cf5d8a1 100644 --- a/resources/configuration.html +++ b/resources/configuration.html @@ -63,7 +63,7 @@ vim: sw=2 ts=2 expandtab ai </head> <body onload="put_config();"> <h1>My Data</h1> - <small>v2.3.3, by bahbka</small> + <small>v2.3.4, by bahbka</small> <hr size="1" /> <form action="javascript: get_config();" id="config_form"> diff --git a/src/js/pebble-js-app.src.js b/src/js/pebble-js-app.src.js index 0be03ec..ad12514 100644 --- a/src/js/pebble-js-app.src.js +++ b/src/js/pebble-js-app.src.js @@ -12,7 +12,8 @@ var MSG = { SHAKE_UPDATE: 7, JSON_RESPONSE: 8, CONFIG: 9, - ERROR: 10 + ERROR: 10, + IN_RETRY: 11 }; var CONTENT_MAX_LENGTH = 900; @@ -98,6 +99,7 @@ function http_request(url) { response["content"] = response["content"].substring(0, CONTENT_MAX_LENGTH); } + window.localStorage.setItem('pebble-my-data-response', JSON.stringify(response)); Pebble.sendAppMessage(response); if (response["auth"] != null) { @@ -188,23 +190,29 @@ Pebble.addEventListener("appmessage", var url = config["url"]; var s = (url.indexOf("?")===-1)?"?":"&"; - if (e.payload["refresh"] == MSG.SELECT_SHORT_PRESS_UPDATE) { - url = url + s + "select=1"; - } else if (e.payload["refresh"] == MSG.SELECT_LONG_PRESS_UPDATE) { - url = url + s + "select=2"; - } else if (e.payload["refresh"] == MSG.UP_SHORT_PRESS_UPDATE) { - url = url + s + "up=1"; - } else if (e.payload["refresh"] == MSG.UP_LONG_PRESS_UPDATE) { - url = url + s + "up=2"; - } else if (e.payload["refresh"] == MSG.DOWN_SHORT_PRESS_UPDATE) { - url = url + s + "down=1"; - } else if (e.payload["refresh"] == MSG.DOWN_LONG_PRESS_UPDATE) { - url = url + s + "down=2"; - } else if (e.payload["refresh"] == MSG.SHAKE_UPDATE) { - url = url + s + "shake=1"; - } + if (e.payload["refresh"] == MSG.IN_RETRY) { + response = window.localStorage.getItem('pebble-my-data-response'); + Pebble.sendAppMessage(JSON.parse(response)); - fetch_data(url); + } else { + if (e.payload["refresh"] == MSG.SELECT_SHORT_PRESS_UPDATE) { + url = url + s + "select=1"; + } else if (e.payload["refresh"] == MSG.SELECT_LONG_PRESS_UPDATE) { + url = url + s + "select=2"; + } else if (e.payload["refresh"] == MSG.UP_SHORT_PRESS_UPDATE) { + url = url + s + "up=1"; + } else if (e.payload["refresh"] == MSG.UP_LONG_PRESS_UPDATE) { + url = url + s + "up=2"; + } else if (e.payload["refresh"] == MSG.DOWN_SHORT_PRESS_UPDATE) { + url = url + s + "down=1"; + } else if (e.payload["refresh"] == MSG.DOWN_LONG_PRESS_UPDATE) { + url = url + s + "down=2"; + } else if (e.payload["refresh"] == MSG.SHAKE_UPDATE) { + url = url + s + "shake=1"; + } + + fetch_data(url); + } } else { Pebble.sendAppMessage({ "msg_type": MSG.JSON_RESPONSE, "content": "URL not defined, check settings in Pebble App" }); diff --git a/src/pebble-my-data.c b/src/pebble-my-data.c index ac701c6..4bbf371 100644 --- a/src/pebble-my-data.c +++ b/src/pebble-my-data.c @@ -54,6 +54,7 @@ bool update_in_progress = false; #define DEFAULT_REFRESH 300*1000 #define RETRY_DELAY 60*1000 +#define IN_RETRY_DELAY 100 #define REQUEST_TIMEOUT 30*1000 #define BLINK_INTERVAL 500 @@ -93,7 +94,8 @@ enum { // msg type MSG_SHAKE_UPDATE, MSG_JSON_RESPONSE, MSG_CONFIG, - MSG_ERROR + MSG_ERROR, + MSG_IN_RETRY }; enum { // themes @@ -486,7 +488,7 @@ void out_failed_handler(DictionaryIterator *failed, AppMessageResult reason, voi void in_dropped_handler(AppMessageResult reason, void *context) { bitmap_layer_set_bitmap(update_icon_layer, update_error_icon_bitmap); update_in_progress = false; - schedule_update(RETRY_DELAY, update_type); + schedule_update(IN_RETRY_DELAY, MSG_IN_RETRY); } // process received data diff --git a/stuff/pebble-my-data.pbw b/stuff/pebble-my-data.pbw Binary files differindex f8dee0a..9468074 100644 --- a/stuff/pebble-my-data.pbw +++ b/stuff/pebble-my-data.pbw |