From 05d2bb903a68573d93b07d4533cfc2ad1726fff0 Mon Sep 17 00:00:00 2001 From: LeJeu <64744459+le-jeu@users.noreply.github.com> Date: Wed, 17 Feb 2021 00:32:41 +0100 Subject: [PATCH] remove obsolete data from portal details cache avoid missing details when getEntities replies that the portal has changed while portal details is still fresh (3min) in cache --- core/code/map_data_render.js | 5 ++++- core/code/portal_detail.js | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/code/map_data_render.js b/core/code/map_data_render.js index 483cdb6a5..e4f236609 100644 --- a/core/code/map_data_render.js +++ b/core/code/map_data_render.js @@ -347,7 +347,10 @@ window.Render.prototype.createPortalEntity = function(ent, details) { // in case of incomplete data while having fresh details in cache, update the portal with those details if (portalDetail.isFresh(guid)) { var oldDetails = portalDetail.get(guid); - if (marker.willUpdate(oldDetails)) + if (data.timestamp > oldDetails.timestamp) { + // data is more recent than the cached details so we remove them from the cache + portalDetail.remove(guid); + } else if (marker.willUpdate(oldDetails)) marker.updateDetails(oldDetails); } diff --git a/core/code/portal_detail.js b/core/code/portal_detail.js index cfb3bc12f..0a12bdd3c 100644 --- a/core/code/portal_detail.js +++ b/core/code/portal_detail.js @@ -25,6 +25,9 @@ window.portalDetail.isFresh = function(guid) { return cache.isFresh(guid); } +window.portalDetail.remove = function(guid) { + return cache.remove(guid); +} var handleResponse = function(deferred, guid, data, success) { if (!data || data.error || !data.result) {