Skip to content

Build your personal knowledge base with Trilium Notes

when note is created, it's automatically present in all cloned parents as well

zadamf479c0e10ef3
diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js
index 20d555f2ca..333e55bf96 100644
--- a/src/public/javascripts/services/tree.js
+++ b/src/public/javascripts/services/tree.js
@@ -611,7 +611,7 @@ async function createNote(node, parentNoteId, target, extraOptions) {
treeCache.add(noteEntity, branchEntity);
- const newNode = {
+ let newNode = {
title: newNoteName,
noteId: branchEntity.noteId,
parentNoteId: parentNoteId,
@@ -649,6 +649,21 @@ async function createNote(node, parentNoteId, target, extraOptions) {
clearSelectedNodes(); // to unmark previously active node
+ // need to refresh because original doesn't have methods like .getParent()
+ newNode = getNodesByNoteId(branchEntity.noteId)[0];
+
+ // following for cycle will make sure that also clones of a parent are refreshed
+ for (const newParentNode of getNodesByNoteId(parentNoteId)) {
+ if (newParentNode.key === newNode.getParent().key) {
+ // we've added a note into this one so no need to refresh
+ continue;
+ }
+
+ await newParentNode.load(true); // force reload to show up new note
+
+ await checkFolderStatus(newParentNode);
+ }
+
return {note, branch};
}