From bff8266f19b87b0925978f844e11bfeed34a6ed9 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Thu, 30 Apr 2015 13:30:00 -0400 Subject: [PATCH] Load children into remotegraph before conflict checks Because loadMultiple doesn't download /full like loadEntity, need to also load children that aren't already being checked.. --- js/id/modes/save.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/js/id/modes/save.js b/js/id/modes/save.js index ce843cd42..d63a939cf 100644 --- a/js/id/modes/save.js +++ b/js/id/modes/save.js @@ -52,11 +52,28 @@ iD.modes.Save = function(context) { showErrors(); } else { + var loadMore = []; _.each(result.data, function(entity) { remoteGraph.replace(entity); toLoad = _.without(toLoad, entity.id); + + // Because loadMultiple doesn't download /full like loadEntity, + // need to also load children that aren't already being checked.. + if (!entity.visible) return; + if (entity.type === 'way') { + loadMore.push.apply(loadMore, + _.difference(entity.nodes, toCheck, toLoad, loadMore)); + } else if (entity.type === 'relation' && entity.isMultipolygon()) { + loadMore.push.apply(loadMore, + _.difference(_.pluck(entity.members, 'id'), toCheck, toLoad, loadMore)); + } }); + if (loadMore.length) { + toLoad.push.apply(toLoad, loadMore); + context.connection().loadMultiple(loadMore, loaded); + } + if (!toLoad.length) { checkConflicts(); }