locally clear refs before processing
This commit is contained in:
@@ -29,6 +29,7 @@ angular.module('app.frontend')
|
||||
modelManager.createRelationshipBetweenItems(note, tag);
|
||||
}
|
||||
|
||||
note.setDirty(true);
|
||||
syncManager.sync();
|
||||
}
|
||||
|
||||
|
||||
@@ -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"]));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -60,11 +60,13 @@ class SNCrypto {
|
||||
}
|
||||
|
||||
base64(text) {
|
||||
return CryptoJS.enc.Utf8.parse(text).toString(CryptoJS.enc.Base64)
|
||||
// return CryptoJS.enc.Utf8.parse(text).toString(CryptoJS.enc.Base64)
|
||||
return window.btoa(text);
|
||||
}
|
||||
|
||||
base64Decode(base64String) {
|
||||
return CryptoJS.enc.Base64.parse(base64String).toString(CryptoJS.enc.Utf8)
|
||||
// return CryptoJS.enc.Base64.parse(base64String).toString(CryptoJS.enc.Utf8)
|
||||
return window.atob(base64String);
|
||||
}
|
||||
|
||||
sha256(text) {
|
||||
|
||||
@@ -168,6 +168,7 @@ class ModelManager {
|
||||
}
|
||||
|
||||
resolveReferencesForItem(item) {
|
||||
item.locallyClearAllReferences();
|
||||
var contentObject = item.contentObject;
|
||||
if(!contentObject.references) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user