mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			54 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			54 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /** Represents mapping between note and parent note */
 | |
| class Branch {
 | |
|     constructor(treeCache, row) {
 | |
|         this.treeCache = treeCache;
 | |
| 
 | |
|         this.update(row);
 | |
|     }
 | |
| 
 | |
|     update(row) {
 | |
|         /** @param {string} primary key */
 | |
|         this.branchId = row.branchId;
 | |
|         /** @param {string} */
 | |
|         this.noteId = row.noteId;
 | |
|         /** @param {string} */
 | |
|         this.parentNoteId = row.parentNoteId;
 | |
|         /** @param {int} */
 | |
|         this.notePosition = row.notePosition;
 | |
|         /** @param {string} */
 | |
|         this.prefix = row.prefix;
 | |
|         /** @param {boolean} */
 | |
|         this.isExpanded = !!row.isExpanded;
 | |
|         /** @param {boolean} */
 | |
|         this.isDeleted = !!row.isDeleted;
 | |
|         /** @param {boolean} */
 | |
|         this.fromSearchNote = !!row.fromSearchNote;
 | |
|     }
 | |
| 
 | |
|     /** @returns {NoteShort} */
 | |
|     async getNote() {
 | |
|         return this.treeCache.getNote(this.noteId);
 | |
|     }
 | |
| 
 | |
|     /** @returns {NoteShort} */
 | |
|     getNoteFromCache() {
 | |
|         return this.treeCache.getNoteFromCache(this.noteId);
 | |
|     }
 | |
| 
 | |
|     /** @returns {NoteShort} */
 | |
|     async getParentNote() {
 | |
|         return this.treeCache.getNote(this.parentNoteId);
 | |
|     }
 | |
| 
 | |
|     /** @returns {boolean} true if it's top level, meaning its parent is root note */
 | |
|     isTopLevel() {
 | |
|         return this.parentNoteId === 'root';
 | |
|     }
 | |
| 
 | |
|     get toString() {
 | |
|         return `Branch(branchId=${this.branchId})`;
 | |
|     }
 | |
| }
 | |
| 
 | |
| export default Branch;
 |