From e31275cf33642b2e853eae7917d8a3c007173d5b Mon Sep 17 00:00:00 2001 From: thecodrr Date: Mon, 22 Feb 2021 10:05:11 +0500 Subject: [PATCH] fix: notebooks are sometimes not added to note --- 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 1bb623b4a..d1991edb3 100644 --- a/packages/core/models/topic.js +++ b/packages/core/models/topic.js @@ -24,7 +24,6 @@ export default class Topic { for (let noteId of noteIds) { let note = this._db.notes.note(noteId); if (this.has(noteId) || !note || note.data.deleted) continue; - topic.notes.push(noteId); let array = note.notebooks || []; const notebookIndex = array.findIndex((nb) => nb.id === this._notebookId); @@ -43,6 +42,8 @@ export default class Topic { id: noteId, notebooks: array, }); + + topic.notes.push(noteId); topic.totalNotes++; } return await this._save(topic); @@ -59,10 +60,10 @@ export default class Topic { let array = note.notebooks; const notebookIndex = array.findIndex((nb) => nb.id === this._notebookId); - if (notebookIndex === -1) return; + if (notebookIndex === -1) break; const topicIndex = array[notebookIndex].topics.indexOf(topic.id); - if (topicIndex === -1) return; + if (topicIndex === -1) break; array[notebookIndex].topics.splice(topicIndex, 1); if (array[notebookIndex].topics.length <= 0)