From f479c0e10ef337830f71adc993bfc0812d595120 Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 29 Mar 2019 23:55:28 +0100 Subject: [PATCH] when note is created, it's automatically present in all cloned parents as well --- src/public/javascripts/services/tree.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js index 20d555f2c..333e55bf9 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}; }