don't allow deleting hoisted note + other related fixes, closes #488

This commit is contained in:
zadam
2019-04-16 21:40:04 +02:00
parent 3760835608
commit 064a11d872
12 changed files with 66 additions and 54 deletions

View File

@@ -12,6 +12,7 @@ const Link = require('../entities/link');
const NoteRevision = require('../entities/note_revision');
const Branch = require('../entities/branch');
const Attribute = require('../entities/attribute');
const hoistedNoteService = require('../services/hoisted_note');
async function getNewNotePosition(parentNoteId, noteData) {
let newNotePos = 0;
@@ -364,7 +365,10 @@ async function deleteNote(branch) {
return;
}
if (branch.branchId === 'root' || branch.noteId === 'root') {
if (branch.branchId === 'root'
|| branch.noteId === 'root'
|| branch.noteId === await hoistedNoteService.getHoistedNoteId()) {
throw new Error("Can't delete root branch/note");
}