fixes references issue
This commit is contained in:
@@ -7,45 +7,9 @@ class ModelManager extends ItemManager {
|
||||
this.dirtyItems = [];
|
||||
}
|
||||
|
||||
// get items() {
|
||||
// return super.items()
|
||||
// }
|
||||
resolveReferences() {
|
||||
super.resolveReferences()
|
||||
|
||||
mapResponseItemsToLocalModels(items) {
|
||||
var models = []
|
||||
for (var json_obj of items) {
|
||||
var item = this.findItem(json_obj["uuid"]);
|
||||
if(json_obj["deleted"] == true) {
|
||||
if(item) {
|
||||
this.deleteItem(item)
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if(item) {
|
||||
_.merge(item, json_obj);
|
||||
} else {
|
||||
item = this.createItem(json_obj);
|
||||
}
|
||||
|
||||
models.push(item)
|
||||
}
|
||||
this.addItems(models)
|
||||
return models;
|
||||
}
|
||||
|
||||
createItem(json_obj) {
|
||||
if(json_obj.content_type == "Note") {
|
||||
return new Note(json_obj);
|
||||
} else if(json_obj.content_type == "Tag") {
|
||||
return new Tag(json_obj);
|
||||
} else {
|
||||
return new Item(json_obj);
|
||||
}
|
||||
}
|
||||
|
||||
addItems(items) {
|
||||
super.addItems(items)
|
||||
this.notes = this.itemsForContentType("Note");
|
||||
this.notes.forEach(function(note){
|
||||
note.updateReferencesLocalMapping();
|
||||
|
||||
Reference in New Issue
Block a user