Skip to content

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

feat: add delete

thecodrr9f4e3158ee44
diff --git a/apps/web/src/components/notebook/index.js b/apps/web/src/components/notebook/index.js
index b61c25892..8cc6052f8 100644
--- a/apps/web/src/components/notebook/index.js
+++ b/apps/web/src/components/notebook/index.js
@@ -2,8 +2,6 @@ import React from "react";
import { Flex, Text } from "rebass";
import * as Icon from "react-feather";
import ListItem from "../list-item";
-import { db, ev } from "../../common";
-import { showSnack } from "../snackbar";
import { store } from "../../stores/notebook-store";
const dropdownRefs = [];
@@ -21,15 +19,7 @@ const menuItems = (notebook, index) => [
{
title: "Delete",
color: "red",
- onClick: () => {
- db.notebooks.delete(notebook.id).then(
- //TODO implement undo
- () => {
- showSnack("Notebook deleted!", Icon.Check);
- ev.emit("refreshNotebooks");
- }
- );
- }
+ onClick: () => store.getState().delete(notebook.id, index)
}
];
diff --git a/apps/web/src/stores/notebook-store.js b/apps/web/src/stores/notebook-store.js
index cb4fde242..141be3154 100644
--- a/apps/web/src/stores/notebook-store.js
+++ b/apps/web/src/stores/notebook-store.js
@@ -15,7 +15,12 @@ function notebookStore(set) {
set(state => state.notebooks.push(nb));
}
},
- delete: function() {},
+ delete: async function(id, index) {
+ await db.notebooks.delete(id);
+ set(state => {
+ state.notebooks.splice(index, 1);
+ });
+ },
update: function() {},
pin: async function(notebook, index) {
await db.notebooks.notebook(notebook).pin();