Fix references bug that prematurely saves data locally before all references could be properly retrieved and built

This commit is contained in:
Mo Bitar
2017-09-05 11:49:12 -05:00
parent 47fc4ef8c2
commit 407a235a15
7 changed files with 43 additions and 18 deletions

View File

@@ -198,20 +198,24 @@ class ModelManager {
}
resolveReferencesForItem(item) {
item.locallyClearAllReferences();
var contentObject = item.contentObject;
// If another client removes an item's references, this client won't pick up the removal unless
// we remove everything not present in the current list of references
item.removeReferencesNotPresentIn(contentObject.references);
if(!contentObject.references) {
return;
}
for(var reference of contentObject.references) {
var referencedItem = this.findItem(reference.uuid);
if(referencedItem) {
item.addItemAsRelationship(referencedItem);
referencedItem.addItemAsRelationship(item);
} else {
// console.log("Unable to find item:", reference.uuid);
// console.log("Unable to find reference:", reference.uuid, "for item:", item);
}
}
}