Skip to content

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

web: fix crash when opening notebook context menu

Abdullah Atta20bef5e70c66
diff --git a/apps/web/src/components/notebook/index.js b/apps/web/src/components/notebook/index.js
index 619728c31..d10d2d2c9 100644
--- a/apps/web/src/components/notebook/index.js
+++ b/apps/web/src/components/notebook/index.js
@@ -142,7 +142,9 @@ const menuItems = [
onClick: async ({ notebook }) => {
const defaultNotebook = db.settings.getDefaultNotebook();
const isDefault =
- defaultNotebook?.id === notebook.id && !defaultNotebook?.topic;
+ defaultNotebook &&
+ defaultNotebook.id === notebook.id &&
+ !defaultNotebook.topic;
await db.settings.setDefaultNotebook(
isDefault ? undefined : { id: notebook.id }
diff --git a/apps/web/src/components/topic/index.js b/apps/web/src/components/topic/index.js
index 91e8178ac..c90ad89fd 100644
--- a/apps/web/src/components/topic/index.js
+++ b/apps/web/src/components/topic/index.js
@@ -94,8 +94,10 @@ const menuItems = [
onClick: async ({ topic }) => {
const defaultNotebook = db.settings.getDefaultNotebook();
const isDefault =
- defaultNotebook?.id === topic.notebookId &&
- defaultNotebook?.topic === topic.id;
+ defaultNotebook &&
+ defaultNotebook.id === topic.notebookId &&
+ defaultNotebook.topic === topic.id;
+
await db.settings.setDefaultNotebook(
isDefault ? undefined : { id: topic.notebookId, topic: topic.id }
);