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: refactor note menu items definition
Abdullah Atta1f7b8ce1edc8
diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.jsindex fee8b6f93..d88e9efb1 100644--- a/apps/web/src/components/note/index.js+++ b/apps/web/src/components/note/index.js@@ -99,7 +99,7 @@ function Note(props) {background: isOpened ? "bgSecondary" : "background"}}menu={{- items: context?.type === "topic" ? topicNoteMenuItems : menuItems,+ items: menuItems,extraData: { note, context }}}onClick={() => {@@ -459,39 +459,12 @@ const menuItems = [await store.get().localOnly(note.id);}},- {- key: "movetotrash",- title: "Move to trash",- color: "error",- iconColor: "error",- icon: Icon.Trash,- disabled: ({ items }) => {- const areAllSynced = items.reduce((prev, curr) => {- if (!prev || !db.notes.note(curr.id).synced()) return false;- return prev;- }, true);- if (!areAllSynced) return notFullySyncedText;-- if (items.length !== 1) return false;-- if (db.monographs.isPublished(items[0].id))- return "Please unpublish this note to move it to trash";- },- onClick: async ({ items }) => {- await Multiselect.moveNotesToTrash(items, items.length > 1);- },- multiSelect: true- }-];--const topicNoteMenuItems = [- ...menuItems,+ { key: "sep3", type: "separator" },{key: "removefromtopic",title: "Remove from topic",icon: Icon.TopicRemove,- color: "error",- iconColor: "error",+ hidden: ({ context }) => context?.type !== "topic",onClick: async ({ items, context }) => {try {if (!context.value?.topic || !context.value?.id)@@ -512,6 +485,29 @@ const topicNoteMenuItems = [}},multiSelect: true+ },+ {+ key: "movetotrash",+ title: "Move to trash",+ color: "error",+ iconColor: "error",+ icon: Icon.Trash,+ disabled: ({ items }) => {+ const areAllSynced = items.reduce((prev, curr) => {+ if (!prev || !db.notes.note(curr.id).synced()) return false;+ return prev;+ }, true);+ if (!areAllSynced) return notFullySyncedText;++ if (items.length !== 1) return false;++ if (db.monographs.isPublished(items[0].id))+ return "Please unpublish this note to move it to trash";+ },+ onClick: async ({ items }) => {+ await Multiselect.moveNotesToTrash(items, items.length > 1);+ },+ multiSelect: true}];