Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: cannot read property topics of undefined

thecodrr840496891639
diff --git a/packages/core/collections/notes.js b/packages/core/collections/notes.js
index 5f28fe5bb..84b56aa46 100644
--- a/packages/core/collections/notes.js
+++ b/packages/core/collections/notes.js
@@ -193,16 +193,21 @@ export default class Notes extends Collection {
let item = this.note(id);
if (!item) continue;
const itemData = qclone(item.data);
+
if (item.notebooks) {
for (let notebook of item.notebooks) {
- for (let topic of notebook.topics) {
- await this._db.notebooks
- .notebook(notebook.id)
- .topics.topic(topic)
- .delete(id);
+ const notebookRef = this._db.notebooks.notebook(notebook.id);
+ if (!notebookRef) continue;
+
+ for (let topicId of notebook.topics) {
+ const topic = notebookRef.topics.topic(topicId);
+ if (!topic) continue;
+
+ await topic.delete(id);
}
}
}
+
for (let tag of item.tags) {
await this._db.tags.untag(tag, id);
}