Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: add topic deletion

thecodrrcd5ee8e72493
diff --git a/apps/web/src/components/menu/index.js b/apps/web/src/components/menu/index.js
index 6569b5d21..a0375124f 100644
--- a/apps/web/src/components/menu/index.js
+++ b/apps/web/src/components/menu/index.js
@@ -33,7 +33,7 @@ function Menu(props) {
</Text>
{props.menuItems.map(
(item) =>
- !item.visible && (
+ (item.visible === undefined || item.visible === true) && (
<Flex
key={item.title}
onClick={(e) => {
diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.js
index 8bccfe942..26f5c00f8 100644
--- a/apps/web/src/components/note/index.js
+++ b/apps/web/src/components/note/index.js
@@ -48,7 +48,7 @@ function menuItems(note, context) {
onlyPro: true,
},
{
- visible: context ? (context.type === "topic" ? true : false) : false,
+ visible: context && context.type === "topic",
title: "Remove",
onClick: async () => {
confirm(
diff --git a/apps/web/src/components/topic/index.js b/apps/web/src/components/topic/index.js
index dfbeadba5..b5f14fdae 100644
--- a/apps/web/src/components/topic/index.js
+++ b/apps/web/src/components/topic/index.js
@@ -1,6 +1,10 @@
import React from "react";
import ListItem from "../list-item";
import { showEditTopicDialog } from "../dialogs/topicdialog";
+import { confirm } from "../dialogs/confirm";
+import * as Icon from "../icons";
+import { db } from "../../common";
+import { store } from "../../stores/notebook-store";
const menuItems = (item) => [
{
@@ -8,11 +12,24 @@ const menuItems = (item) => [
onClick: () => {
showEditTopicDialog(item);
},
- visible: item.title === "General",
+ visible: item.title !== "General",
},
{
title: "Delete",
+ visible: item.title !== "General",
color: "red",
+ onClick: () => {
+ confirm(
+ Icon.Trash,
+ "Delete Topic",
+ "Are you sure you want to delete this topic?"
+ ).then(async (res) => {
+ if (res) {
+ await db.notebooks.notebook(item.notebookId).topics.delete(item.id);
+ store.setSelectedNotebookTopics(item.notebookId);
+ }
+ });
+ },
},
];