From 081b8b126adf5492b76f03ae6a37cd4cf3d77107 Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 20 Feb 2021 21:28:22 +0100 Subject: [PATCH] fix note_reordering not updating note cache --- src/routes/api/tree.js | 4 ++++ src/services/tree.js | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/routes/api/tree.js b/src/routes/api/tree.js index 52d529128..fc795578c 100644 --- a/src/routes/api/tree.js +++ b/src/routes/api/tree.js @@ -135,6 +135,10 @@ function getTree(req) { } } + if (!(subTreeNoteId in noteCache.notes)) { + return [404, `Note ${subTreeNoteId} not found in the cache`]; + } + collect(noteCache.notes[subTreeNoteId]); return getNotesAndBranchesAndAttributes(collectedNoteIds); diff --git a/src/services/tree.js b/src/services/tree.js index 582517c36..16a6ac244 100644 --- a/src/services/tree.js +++ b/src/services/tree.js @@ -5,6 +5,7 @@ const repository = require('./repository'); const Branch = require('../entities/branch'); const entityChangesService = require('./entity_changes.js'); const protectedSessionService = require('./protected_session'); +const noteCache = require('./note_cache/note_cache'); function getNotes(noteIds) { // we return also deleted notes which have been specifically asked for @@ -134,6 +135,8 @@ function sortNotesAlphabetically(parentNoteId, directoriesFirst = false) { sql.execute("UPDATE branches SET notePosition = ? WHERE branchId = ?", [position, note.branchId]); + noteCache.branches[note.branchId].notePosition = position; + position += 10; }