web: fix crash when opening notebook context menu

This commit is contained in:
Abdullah Atta
2023-06-05 19:05:39 +05:00
parent c9b45875a0
commit 20bef5e70c
2 changed files with 7 additions and 3 deletions

View File

@@ -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 }

View File

@@ -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 }
);