Skip to content

Commit 05d2bb9

Browse files
committed
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
1 parent 86fcc1a commit 05d2bb9

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

core/code/map_data_render.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,10 @@ window.Render.prototype.createPortalEntity = function(ent, details) {
347347
// in case of incomplete data while having fresh details in cache, update the portal with those details
348348
if (portalDetail.isFresh(guid)) {
349349
var oldDetails = portalDetail.get(guid);
350-
if (marker.willUpdate(oldDetails))
350+
if (data.timestamp > oldDetails.timestamp) {
351+
// data is more recent than the cached details so we remove them from the cache
352+
portalDetail.remove(guid);
353+
} else if (marker.willUpdate(oldDetails))
351354
marker.updateDetails(oldDetails);
352355
}
353356

core/code/portal_detail.js

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ window.portalDetail.isFresh = function(guid) {
2525
return cache.isFresh(guid);
2626
}
2727

28+
window.portalDetail.remove = function(guid) {
29+
return cache.remove(guid);
30+
}
2831

2932
var handleResponse = function(deferred, guid, data, success) {
3033
if (!data || data.error || !data.result) {

0 commit comments

Comments
 (0)