From ee6479ff48da4ccfcfc86d6a6ab9178f4a7fdb0c Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Thu, 18 Jun 2015 11:47:14 -0400 Subject: [PATCH] During localstorage restore, fetch older version of childnode if needed This together with 8398fd7 closes #2142 --- js/id/core/history.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/js/id/core/history.js b/js/id/core/history.js index 03c91d8d5..585005bd8 100644 --- a/js/id/core/history.js +++ b/js/id/core/history.js @@ -277,7 +277,7 @@ iD.History = function(context) { .value(); if (!_.isEmpty(missing)) { - context.connection().loadMultiple(missing, function(err, result) { + var childNodesLoaded = function(err, result) { if (err) return; var visible = _.groupBy(result.data, 'visible'); @@ -285,10 +285,15 @@ iD.History = function(context) { stack[0].graph.rebase(visible.true, _.pluck(stack, 'graph'), false); tree.rebase(visible.true, false); } - // if (!_.isEmpty(visible.false)) { - // todo: something here! - // } - }); + + // fetch older versions of nodes that were deleted.. + _.each(visible.false, function(entity) { + context.connection() + .loadEntityVersion(entity.id, +entity.version - 1, childNodesLoaded); + }); + }; + + context.connection().loadMultiple(missing, childNodesLoaded); } } }