A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: add support for setting default notebook/topic
Abdullah Atta6c3583c9e543
diff --git a/apps/web/src/components/notebook/index.js b/apps/web/src/components/notebook/index.jsindex ecae695b3..619728c31 100644--- a/apps/web/src/components/notebook/index.js+++ b/apps/web/src/components/notebook/index.js@@ -130,6 +130,25 @@ const menuItems = [icon: Icon.NotebookEdit,onClick: ({ notebook }) => hashNavigate(`/notebooks/${notebook.id}/edit`)},+ {+ key: "set-as-default",+ title: "Set as default",+ checked: ({ notebook }) => {+ const defaultNotebook = db.settings.getDefaultNotebook();+ return defaultNotebook.id === notebook.id && !defaultNotebook.topic;+ },++ icon: Icon.Notebook,+ onClick: async ({ notebook }) => {+ const defaultNotebook = db.settings.getDefaultNotebook();+ const isDefault =+ defaultNotebook?.id === notebook.id && !defaultNotebook?.topic;++ await db.settings.setDefaultNotebook(+ isDefault ? undefined : { id: notebook.id }+ );+ }+ },{key: "pin",icon: Icon.Pin,diff --git a/apps/web/src/components/topic/index.js b/apps/web/src/components/topic/index.jsindex 7ab133914..91e8178ac 100644--- a/apps/web/src/components/topic/index.js+++ b/apps/web/src/components/topic/index.js@@ -80,6 +80,27 @@ const menuItems = [onClick: ({ topic }) =>hashNavigate(`/notebooks/${topic.notebookId}/topics/${topic.id}/edit`)},+ {+ key: "set-as-default",+ title: "Set as default",+ checked: ({ topic }) => {+ const defaultNotebook = db.settings.getDefaultNotebook();+ return (+ defaultNotebook?.id === topic.notebookId &&+ defaultNotebook?.topic === topic.id+ );+ },+ icon: Icon.Topic,+ onClick: async ({ topic }) => {+ const defaultNotebook = db.settings.getDefaultNotebook();+ const isDefault =+ defaultNotebook?.id === topic.notebookId &&+ defaultNotebook?.topic === topic.id;+ await db.settings.setDefaultNotebook(+ isDefault ? undefined : { id: topic.notebookId, topic: topic.id }+ );+ }+ },{key: "shortcut",title: ({ topic }) =>diff --git a/apps/web/src/stores/editor-store.js b/apps/web/src/stores/editor-store.jsindex b9596cb8c..8283ce81e 100644--- a/apps/web/src/stores/editor-store.js+++ b/apps/web/src/stores/editor-store.js@@ -201,6 +201,8 @@ class EditorStore extends BaseStore {else if (type === "tag") await db.notes.note(id).tag(value);// update the note.note = db.notes.note(id)?.data;+ } else if (!sessionId && db.settings.getDefaultNotebook()) {+ await db.notes.addToNotebook(db.settings.getDefaultNotebook(), id);}const shouldRefreshNotes =