Fixes angular digest loop when note has more than 10 tags

This commit is contained in:
Mo Bitar
2018-02-18 14:15:03 -06:00
parent f260476269
commit 4289d4806d
3 changed files with 13 additions and 4 deletions

View File

@@ -33,6 +33,8 @@ class Note extends Item {
} }
addItemAsRelationship(item) { addItemAsRelationship(item) {
this.savedTagsString = null;
if(item.content_type == "Tag") { if(item.content_type == "Tag") {
if(!_.find(this.tags, item)) { if(!_.find(this.tags, item)) {
this.tags.push(item); this.tags.push(item);
@@ -42,6 +44,8 @@ class Note extends Item {
} }
removeItemAsRelationship(item) { removeItemAsRelationship(item) {
this.savedTagsString = null;
if(item.content_type == "Tag") { if(item.content_type == "Tag") {
_.pull(this.tags, item); _.pull(this.tags, item);
} }
@@ -49,6 +53,8 @@ class Note extends Item {
} }
removeAndDirtyAllRelationships() { removeAndDirtyAllRelationships() {
this.savedTagsString = null;
this.tags.forEach(function(tag){ this.tags.forEach(function(tag){
_.pull(tag.notes, this); _.pull(tag.notes, this);
tag.setDirty(true); tag.setDirty(true);
@@ -57,6 +63,8 @@ class Note extends Item {
} }
removeReferencesNotPresentIn(references) { removeReferencesNotPresentIn(references) {
this.savedTagsString = null;
super.removeReferencesNotPresentIn(references); super.removeReferencesNotPresentIn(references);
var uuids = references.map(function(ref){return ref.uuid}); var uuids = references.map(function(ref){return ref.uuid});
@@ -108,6 +116,7 @@ class Note extends Item {
} }
tagsString() { tagsString() {
return Tag.arrayToDisplayString(this.tags); this.savedTagsString = Tag.arrayToDisplayString(this.tags);
return this.savedTagsString;
} }
} }

View File

@@ -55,7 +55,7 @@
%strong.medium Archived %strong.medium Archived
.tags-string{"ng-if" => "ctrl.shouldShowTags(note)"} .tags-string{"ng-if" => "ctrl.shouldShowTags(note)"}
.faded {{note.tagsString()}} .faded {{note.savedTagsString || note.tagsString()}}
.name{"ng-if" => "note.title"} .name{"ng-if" => "note.title"}
{{note.title}} {{note.title}}