Skip to content

Commit

Permalink
remove obsolete data from portal details cache
Browse files Browse the repository at this point in the history
avoid missing details when getEntities replies that the portal has changed
while portal details is still fresh (3min) in cache
  • Loading branch information
le-jeu committed Feb 17, 2021
1 parent 86fcc1a commit 05d2bb9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/code/map_data_render.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 3 additions & 0 deletions core/code/portal_detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 05d2bb9

Please sign in to comment.