recent notes are now keyed by note tree id which simplifies things

This commit is contained in:
azivner
2017-12-03 10:06:53 -05:00
parent 41f089b3f4
commit 15faefe8a3
10 changed files with 36 additions and 54 deletions

View File

@@ -1,28 +1,20 @@
"use strict";
const treeChanges = (function() {
async function moveBeforeNode(node, beforeNode, changeInPath = true) {
async function moveBeforeNode(node, beforeNode) {
await server.put('notes/' + node.data.note_tree_id + '/move-before/' + beforeNode.data.note_tree_id);
node.moveTo(beforeNode, 'before');
if (changeInPath) {
recentNotes.removeRecentNote(noteTree.getCurrentNotePath());
noteTree.setCurrentNotePathToHash(node);
}
noteTree.setCurrentNotePathToHash(node);
}
async function moveAfterNode(node, afterNode, changeInPath = true) {
async function moveAfterNode(node, afterNode) {
await server.put('notes/' + node.data.note_tree_id + '/move-after/' + afterNode.data.note_tree_id);
node.moveTo(afterNode, 'after');
if (changeInPath) {
recentNotes.removeRecentNote(noteTree.getCurrentNotePath());
noteTree.setCurrentNotePathToHash(node);
}
noteTree.setCurrentNotePathToHash(node);
}
// beware that first arg is noteId and second is noteTreeId!
@@ -47,8 +39,6 @@ const treeChanges = (function() {
toNode.folder = true;
toNode.renderTitle();
recentNotes.removeRecentNote(noteTree.getCurrentNotePath());
noteTree.setCurrentNotePathToHash(node);
}
@@ -75,8 +65,6 @@ const treeChanges = (function() {
node.getParent().renderTitle();
}
recentNotes.removeRecentNote(noteTree.getCurrentNotePath());
let next = node.getNextSibling();
if (!next) {
next = node.getParent();