diff --git a/code/map_data.js b/code/map_data.js index 517e84bb..b7afe533 100644 --- a/code/map_data.js +++ b/code/map_data.js @@ -49,17 +49,25 @@ window.requestData = function() { $.each(tiles, function(ind, tls) { data = { minLevelOfDetail: -1 }; data.boundsParamsList = tls; - window.requests.add(window.postAjax('getThinnedEntitiesV2', data, window.handleDataResponse, portalRenderLimit.handleFailRequest)); + window.requests.add(window.postAjax('getThinnedEntitiesV2', data, window.handleDataResponse, window.handleFailedRequest)); }); } +// Handle failed map data request +window.handleFailedRequest = function() { + if(requests.isLastRequest('getThinnedEntitiesV2')) { + var leftOverPortals = portalRenderLimit.mergeLowLevelPortals(null); + handlePortalsRender(leftOverPortals); + } +} + // works on map data response and ensures entities are drawn/updated. window.handleDataResponse = function(data, textStatus, jqXHR) { // remove from active ajax queries list if(!data || !data.result) { window.failedRequestCount++; console.warn(data); - portalRenderLimit.handleFailRequest(); + handleFailedRequest(); return; } diff --git a/code/portal_render_limit.js b/code/portal_render_limit.js index 0ab58107..ec4e93a2 100644 --- a/code/portal_render_limit.js +++ b/code/portal_render_limit.js @@ -82,20 +82,13 @@ window.portalRenderLimit.splitOrMergeLowLevelPortals = function(originPortals) { portalRenderLimit.resetCounting(); portalRenderLimit.countingPortals(originPortals); - var resultPortals = portalRenderLimit.isLastRequest() + var resultPortals = requests.isLastRequest('getThinnedEntitiesV2') ? portalRenderLimit.mergeLowLevelPortals(originPortals) : portalRenderLimit.splitLowLevelPortals(originPortals); return resultPortals; } -window.portalRenderLimit.handleFailRequest = function() { - if(portalRenderLimit.isLastRequest()) { - var resultPortals = portalRenderLimit.mergeLowLevelPortals(null); - handlePortalsRender(resultPortals); - } -} - window.portalRenderLimit.countingPortals = function(portals) { $.each(portals, function(ind, portal) { var portalGuid = portal[0]; @@ -134,17 +127,6 @@ window.portalRenderLimit.mergeLowLevelPortals = function(appendTo) { return resultPortals; } -window.portalRenderLimit.isLastRequest = function() { - var result = true; - $.each(window.activeRequests, function(ind, req) { - if(req.action === 'getThinnedEntitiesV2') { - result = false; - return false; - } - }); - return result; -} - window.portalRenderLimit.getMinLevel = function() { if(!portalRenderLimit.initialized) return -1; if(!portalRenderLimit.minLevelSet) portalRenderLimit.setMinLevel(); diff --git a/code/request_handling.js b/code/request_handling.js index 6fe0acd3..6766fd5f 100644 --- a/code/request_handling.js +++ b/code/request_handling.js @@ -111,3 +111,14 @@ window.requests._callOnRefreshFunctions = function() { window.requests.addRefreshFunction = function(f) { window.requests._onRefreshFunctions.push(f); } + +window.requests.isLastRequest = function(action) { + var result = true; + $.each(window.activeRequests, function(ind, req) { + if(req.action === action) { + result = false; + return false; + } + }); + return result; +} \ No newline at end of file