From 00c8ff4f6911c48250889cd47b79e4893ce93386 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Sun, 1 Jul 2018 22:50:28 -0400 Subject: [PATCH] Don't add notes to the _seenEntity cache re: https://github.com/openstreetmap/iD/commit/229484a940eeb1d8ef08495c39642276c599c323#commitcomment-29560519 --- modules/services/osm.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/services/osm.js b/modules/services/osm.js index 037d23003..d0a9b933b 100644 --- a/modules/services/osm.js +++ b/modules/services/osm.js @@ -237,11 +237,11 @@ function parse(xml, callback, options) { uid = child.getElementsByTagName('id')[0].textContent; } else { uid = osmEntity.id.fromOSM(child.nodeName, child.attributes.id.value); + if (options.cache && _seenEntity[uid]) { + return null; // avoid reparsing a "seen" entity + } } - if (options.cache && _seenEntity[uid]) { - return null; - } return parser(child, uid); } @@ -326,7 +326,7 @@ export default { // Logout and retry the request.. if (isAuthenticated && err && (err.status === 400 || err.status === 401 || err.status === 403)) { that.logout(); - that.loadFromAPI(path, callback); + that.loadFromAPI(path, callback, options); // else, no retry.. } else { @@ -343,7 +343,7 @@ export default { parse(xml, function (entities) { if (options.cache) { for (var i in entities) { - _seenEntity[entities[i].id] = true; + _seenEntity[entities[i].id] = true; // avoid re-parsing again later } } callback(null, entities); @@ -707,6 +707,7 @@ export default { dispatch.call('loading'); // start the spinner } + var options = { cache: !loadingNotes }; cache.inflight[id] = that.loadFromAPI( path + tile.extent.toParam(), function(err, parsed) { @@ -726,8 +727,8 @@ export default { dispatch.call('loaded'); // stop the spinner } } - - } + }, + options ); }); },