From 20bef5e70c661a5696dbe2404ec52d7f5e8ee5f0 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Mon, 5 Jun 2023 19:05:39 +0500 Subject: [PATCH] web: fix crash when opening notebook context menu --- apps/web/src/components/notebook/index.js | 4 +++- apps/web/src/components/topic/index.js | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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 } );