Skip to content

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

web: fix crash on opening notebook context menu

Abdullah Atta92e9cd740fb6
diff --git a/apps/web/src/components/notebook/index.js b/apps/web/src/components/notebook/index.js
index d10d2d2c9..c32cce50e 100644
--- a/apps/web/src/components/notebook/index.js
+++ b/apps/web/src/components/notebook/index.js
@@ -135,16 +135,14 @@ const menuItems = [
title: "Set as default",
checked: ({ notebook }) => {
const defaultNotebook = db.settings.getDefaultNotebook();
- return defaultNotebook.id === notebook.id && !defaultNotebook.topic;
+ return defaultNotebook?.id === notebook.id && !defaultNotebook?.topic;
},
icon: Icon.Notebook,
onClick: async ({ notebook }) => {
const defaultNotebook = db.settings.getDefaultNotebook();
const isDefault =
- defaultNotebook &&
- defaultNotebook.id === notebook.id &&
- !defaultNotebook.topic;
+ 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 c90ad89fd..c43f89030 100644
--- a/apps/web/src/components/topic/index.js
+++ b/apps/web/src/components/topic/index.js
@@ -94,9 +94,8 @@ const menuItems = [
onClick: async ({ topic }) => {
const defaultNotebook = db.settings.getDefaultNotebook();
const isDefault =
- defaultNotebook &&
- defaultNotebook.id === topic.notebookId &&
- defaultNotebook.topic === topic.id;
+ defaultNotebook?.id === topic.notebookId &&
+ defaultNotebook?.topic === topic.id;
await db.settings.setDefaultNotebook(
isDefault ? undefined : { id: topic.notebookId, topic: topic.id }