Skip to content

Commit

Permalink
Merge pull request #177 from AlvaroLQueiroz/iss176
Browse files Browse the repository at this point in the history
Fix #176
  • Loading branch information
AlvaroLQueiroz committed Jun 23, 2017
2 parents 5a96e44 + 751553b commit 1238765
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions notifications/static/notifications/notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,18 @@ function fetch_api_data() {
if (registered_functions.length > 0) {
//only fetch data if a function is setup
var r = new XMLHttpRequest();
r.addEventListener('readystatechange', function(event){
if (this.readyState === 4){
if (this.status === 200){
consecutive_misfires = 0;
var data = JSON.parse(r.responseText);
registered_functions.forEach(function (func) { func(data); });
}else{
consecutive_misfires++;
}
}
})
r.open("GET", notify_api_url+'?max='+notify_fetch_count, true);
r.onerror = function () {
consecutive_misfires++;
}
r.onready = function () {
consecutive_misfires = 0;
var data = JSON.parse(r.responseText);
registered_functions.forEach(function (func) { func(data); });
}
r.send();
}
if (consecutive_misfires < 10) {
Expand Down

0 comments on commit 1238765

Please sign in to comment.