Skip to content

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

fix: check for nulls when getting settings pins

thecodrr25c08198fb89
diff --git a/packages/core/api/settings.js b/packages/core/api/settings.js
index 6c01b0db3..aafaefc73 100644
--- a/packages/core/api/settings.js
+++ b/packages/core/api/settings.js
@@ -69,13 +69,18 @@ class Settings {
get pins() {
return this._settings.pins.reduce((prev, pin) => {
+ if (!pin || !pin.data) return;
+
let item;
if (pin.type === "notebook") {
- item = this._db.notebooks.notebook(pin.data.id).data;
+ const notebook = this._db.notebooks.notebook(pin.data.id);
+ item = notebook ? notebook.data : null;
} else if (pin.type === "topic") {
- item = this._db.notebooks
- .notebook(pin.data.notebookId)
- .topics.topic(pin.data.id)._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;
} else if (pin.type === "tag") {
item = this._db.tags.tag(pin.data.id);
}