From dfc3e36d9e2b50c877d3f4ea54d1021622ab54b4 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Mon, 14 Oct 2019 21:23:06 +0200 Subject: [PATCH] make fetching more robust when low on resources --- html/planeObject.js | 2 +- html/script.js | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/html/planeObject.js b/html/planeObject.js index 96390f7..de4d211 100644 --- a/html/planeObject.js +++ b/html/planeObject.js @@ -168,7 +168,7 @@ PlaneObject.prototype.isFiltered = function() { return true; } - if (filterTISB && this.dataSource == "tisb") { + if (filterTISB && this.dataSource == "tisb" && this.type != "tisb_icao") { return true; } diff --git a/html/script.js b/html/script.js index 24c7455..84c85af 100644 --- a/html/script.js +++ b/html/script.js @@ -233,11 +233,11 @@ function fetchData() { var center = ol.proj.toLonLat(OLMap.getView().getCenter(), OLMap.getView().getProjection()); localStorage['CenterLon'] = CenterLon = center[0]; localStorage['CenterLat'] = CenterLat = center[1]; - if (FetchPending != null && FetchPending.state() == 'pending') { + if (FetchPending != null) { // don't double up on fetches, let the last one resolve return; } - if (FetchPendingUAT != null && FetchPendingUAT.state() == 'pending') { + if (FetchPendingUAT != null) { // don't double up on fetches, let the last one resolve return; } @@ -272,8 +272,12 @@ function fetchData() { cache: false, dataType: 'json' }); - $.when(FetchPendingUAT).done(function(data) { + FetchPendingUAT.done(function(data) { uat_data = data; + FetchPendingUAT = null; + }); + FetchPendingUAT.fail(function(jqxhr, status, error) { + FetchPendingUAT = null; }); } FetchPending = $.ajax({ url: 'data/aircraft.json', @@ -281,9 +285,10 @@ function fetchData() { cache: false, dataType: 'json' }); FetchPending.done(function(data) { - if (data == null) + if (data == null) { + FetchPending = null; return; - + } // experimental stuff /* @@ -337,6 +342,7 @@ function fetchData() { $("#update_error").css('display','none'); } + FetchPending = null; }); FetchPending.fail(function(jqxhr, status, error) { @@ -344,6 +350,7 @@ function fetchData() { $("#update_error").css('display','block'); StaleReceiverCount++; fetchData(); + FetchPending = null; }); }