A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix: cannot read properties of undefined (topics)
thecodrrf14c2c933512
diff --git a/packages/core/api/settings.js b/packages/core/api/settings.jsindex aa9ff7eb9..1c063a8f2 100644--- a/packages/core/api/settings.js+++ b/packages/core/api/settings.js@@ -109,16 +109,16 @@ class Settings {return this._settings.pins.reduce((prev, pin) => {if (!pin || !pin.data) return;- let item;+ let item = null;if (pin.type === "notebook") {const notebook = this._db.notebooks.notebook(pin.data.id);item = notebook ? notebook.data : null;} else if (pin.type === "topic") {const notebook = this._db.notebooks.notebook(pin.data.notebookId);- if (!notebook) item = null;- const topic = notebook.topics.topic(pin.data.id);- if (!topic) item = null;- item = topic._topic;+ if (notebook) {+ const topic = notebook.topics.topic(pin.data.id);+ if (topic) item = topic._topic;+ }} else if (pin.type === "tag") {item = this._db.tags.tag(pin.data.id);}diff --git a/packages/core/collections/notebooks.js b/packages/core/collections/notebooks.jsindex 947dd2b05..e18076c68 100644--- a/packages/core/collections/notebooks.js+++ b/packages/core/collections/notebooks.js@@ -136,7 +136,7 @@ export default class Notebooks extends Collection {async repairReferences() {for (let notebook of this.all) {- const _notebook = this.notebook(notebook.id);+ const _notebook = this.notebook(notebook);for (let topic of notebook.topics) {const _topic = _notebook.topics.topic(topic.id);await _topic.add(...topic.notes);diff --git a/packages/core/collections/notes.js b/packages/core/collections/notes.jsindex bc0baa6fb..3e89d8edf 100644--- a/packages/core/collections/notes.js+++ b/packages/core/collections/notes.js@@ -251,12 +251,15 @@ export default class Notes extends Collection {for (let notebook of notebooks) {const nb = this._db.notebooks.notebook(notebook.id);- for (let topic of notebook.topics) {- const _topic = nb.topics.topic(topic);- if (!_topic || !_topic.has(note.id)) {- deleteItem(notebook.topics, topic);- await this.add(note);- continue;++ if (nb) {+ for (let topic of notebook.topics) {+ const _topic = nb.topics.topic(topic);+ if (!_topic || !_topic.has(note.id)) {+ deleteItem(notebook.topics, topic);+ await this.add(note);+ continue;+ }}}