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

This commit is contained in:
zadam 2019-03-29 23:55:28 +01:00
parent 0f32154b91
commit f479c0e10e

View File

@ -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};
}