During localstorage restore, fetch older version of childnode if needed

This together with 8398fd7 closes #2142
This commit is contained in:
Bryan Housel
2015-06-18 11:47:14 -04:00
parent f4d93c442e
commit ee6479ff48

View File

@@ -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);
}
}
}