mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	fix template attribute cycle in note cache
This commit is contained in:
		@@ -60,12 +60,21 @@ class Note {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /** @return {Attribute[]} */
 | 
					    /** @return {Attribute[]} */
 | 
				
			||||||
    get attributes() {
 | 
					    get attributes() {
 | 
				
			||||||
 | 
					        return this.__getAttributes([]);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    __getAttributes(path) {
 | 
				
			||||||
 | 
					        if (path.includes(this.noteId)) {
 | 
				
			||||||
 | 
					            return [];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!this.attributeCache) {
 | 
					        if (!this.attributeCache) {
 | 
				
			||||||
            const parentAttributes = this.ownedAttributes.slice();
 | 
					            const parentAttributes = this.ownedAttributes.slice();
 | 
				
			||||||
 | 
					            const newPath = [...path, this.noteId];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (this.noteId !== 'root') {
 | 
					            if (this.noteId !== 'root') {
 | 
				
			||||||
                for (const parentNote of this.parents) {
 | 
					                for (const parentNote of this.parents) {
 | 
				
			||||||
                    parentAttributes.push(...parentNote.inheritableAttributes);
 | 
					                    parentAttributes.push(...parentNote.__getInheritableAttributes(newPath));
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -76,7 +85,7 @@ class Note {
 | 
				
			|||||||
                    const templateNote = this.noteCache.notes[ownedAttr.value];
 | 
					                    const templateNote = this.noteCache.notes[ownedAttr.value];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (templateNote) {
 | 
					                    if (templateNote) {
 | 
				
			||||||
                        templateAttributes.push(...templateNote.attributes);
 | 
					                        templateAttributes.push(...templateNote.__getAttributes(newPath));
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -95,9 +104,13 @@ class Note {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /** @return {Attribute[]} */
 | 
					    /** @return {Attribute[]} */
 | 
				
			||||||
    get inheritableAttributes() {
 | 
					    __getInheritableAttributes(path) {
 | 
				
			||||||
 | 
					        if (path.includes(this.noteId)) {
 | 
				
			||||||
 | 
					            return [];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!this.inheritableAttributeCache) {
 | 
					        if (!this.inheritableAttributeCache) {
 | 
				
			||||||
            this.attributes; // will refresh also this.inheritableAttributeCache
 | 
					            this.__getAttributes(path); // will refresh also this.inheritableAttributeCache
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return this.inheritableAttributeCache;
 | 
					        return this.inheritableAttributeCache;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user