fixed duplicated notes after creating into a folder which wasn't yet loaded

This commit is contained in:
zadam 2019-07-06 13:14:33 +02:00
parent 2b44f3bc76
commit ddf381f92d

View File

@ -635,18 +635,18 @@ async function createNote(node, parentNoteId, target, extraOptions = {}) {
}; };
if (target === 'after') { if (target === 'after') {
console.log(`Appending node...`); // to debug duplicated nodes
await node.appendSibling(newNode).setActive(true); await node.appendSibling(newNode).setActive(true);
} }
else if (target === 'into') { else if (target === 'into') {
if (!node.getChildren() && node.isFolder()) { if (!node.getChildren() && node.isFolder()) {
// folder is not loaded - load will bring up the note since it was already put into cache
await node.load(true);
await node.setExpanded(); await node.setExpanded();
} }
else {
console.log(`Adding node as child...`); // to debug duplicated nodes node.addChildren(newNode);
}
node.addChildren(newNode);
await node.getLastChild().setActive(true); await node.getLastChild().setActive(true);
@ -742,10 +742,12 @@ utils.bindShortcut('ctrl+o', async () => {
async function createNoteInto() { async function createNoteInto() {
const node = getActiveNode(); const node = getActiveNode();
await createNote(node, node.data.noteId, 'into', { if (node) {
isProtected: node.data.isProtected, await createNote(node, node.data.noteId, 'into', {
saveSelection: true isProtected: node.data.isProtected,
}); saveSelection: true
});
}
} }
async function checkFolderStatus(node) { async function checkFolderStatus(node) {