From c838a719310ce6f1bd145493f58d516d8acd39cc Mon Sep 17 00:00:00 2001 From: thecodrr Date: Wed, 1 Jan 2020 12:34:19 +0500 Subject: [PATCH] feat: allow moving note without a notebook --- packages/core/api/database.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/core/api/database.js b/packages/core/api/database.js index a18bf6550..79e5ac16b 100644 --- a/packages/core/api/database.js +++ b/packages/core/api/database.js @@ -357,16 +357,18 @@ class Database { async moveNote(noteId, from, to) { if ( !noteId || - !from || + (from && (!from.notebook || !from.topic)) || !to || - !from.notebook || !to.notebook || - !from.topic || !to.topic || (from.notebook === to.notebook && from.topic === to.topic) //moving to same notebook and topic shouldn't be possible ) return false; - if (await this.deleteNoteFromTopic(from.notebook, from.topic, noteId)) { + if (!from) { + return await this.addNoteToTopic(to.notebook, to.topic, noteId); + } else if ( + await this.deleteNoteFromTopic(from.notebook, from.topic, noteId) + ) { return await this.addNoteToTopic(to.notebook, to.topic, noteId); } return false;