From 97cbbbda0cf4a3cc9f766da36ea99e8672b5be3a Mon Sep 17 00:00:00 2001 From: thecodrr Date: Mon, 22 Feb 2021 10:12:45 +0500 Subject: [PATCH] fix: remove note from topic even if it has no nb --- packages/core/models/topic.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/core/models/topic.js b/packages/core/models/topic.js index d1991edb3..067f154aa 100644 --- a/packages/core/models/topic.js +++ b/packages/core/models/topic.js @@ -53,12 +53,13 @@ export default class Topic { const topic = qclone(this._topic); for (let noteId of noteIds) { let note = this._db.notes.note(noteId); - if (!this.has(noteId) || !note || note.data.deleted || !note.notebooks) - return this; + + if (!this.has(noteId) || !note || note.data.deleted) return this; + let index = topic.notes.indexOf(noteId); topic.notes.splice(index, 1); - let array = note.notebooks; + let array = note.notebooks || []; const notebookIndex = array.findIndex((nb) => nb.id === this._notebookId); if (notebookIndex === -1) break;