web: fix crash on opening notebook context menu

This commit is contained in:
Abdullah Atta
2023-06-05 19:06:53 +05:00
parent 20bef5e70c
commit 92e9cd740f
2 changed files with 4 additions and 7 deletions

View File

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

View File

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