locally clear refs before processing

This commit is contained in:
Mo Bitar
2017-02-19 22:57:36 -06:00
parent f7b1759cd6
commit a0d582db52
9 changed files with 32 additions and 6 deletions

View File

@@ -37,7 +37,7 @@ class Item {
updateFromJSON(json) {
_.merge(this, json);
if(this.created_at) {
this.created_at = new Date(this.created_at);
this.updated_at = new Date(this.updated_at);
@@ -113,6 +113,10 @@ class Item {
this.setDirty(true);
}
locallyClearAllReferences() {
}
mergeMetadataFromItem(item) {
_.merge(this, _.omit(item, ["content"]));
}

View File

@@ -56,6 +56,14 @@ class Note extends Item {
this.tags = [];
}
locallyClearAllReferences() {
super.locallyClearAllReferences();
this.tags.forEach(function(tag){
_.pull(tag.notes, this);
}.bind(this))
this.tags = [];
}
isBeingRemovedLocally() {
this.tags.forEach(function(tag){
_.pull(tag.notes, this);

View File

@@ -55,6 +55,15 @@ class Tag extends Item {
this.notes = [];
}
locallyClearAllReferences() {
super.locallyClearAllReferences();
this.notes.forEach(function(note){
_.pull(note.tags, this);
}.bind(this))
this.notes = [];
}
isBeingRemovedLocally() {
this.notes.forEach(function(note){
_.pull(note.tags, this);