Skip to content

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

feat: notebook delete toast

alihamuh1ac00443429e
diff --git a/apps/web/src/common/toasts.js b/apps/web/src/common/toasts.js
index 272367e1c..d9c9d5833 100644
--- a/apps/web/src/common/toasts.js
+++ b/apps/web/src/common/toasts.js
@@ -32,9 +32,9 @@ function showNotesMovedToast(note, noteIds, notebook) {
function showNoteDeleted(note) {
const undoAction = () => {
let deletedNotes = db.trash.all;
- deletedNotes.forEach((element) => {
+ deletedNotes.forEach(async (element) => {
if (element.itemId === note) {
- db.trash.restore(element.id);
+ await db.trash.restore(element.id);
notestore.refresh();
}
});
@@ -65,9 +65,26 @@ async function showUnpinnedToast(itemId, itemType) {
var toast = showToast("success", messageText, actions);
}
+function showNoteBookDeleted(notebook) {
+ const undoAction = () => {
+ let deletedNotes = db.trash.all;
+ deletedNotes.forEach(async (element) => {
+ if (element.itemId === notebook) {
+ await db.trash.restore(element.id);
+ nbstore.refresh();
+ }
+ });
+ };
+
+ let actions = [{ text: "Undo", onClick: undoAction }];
+
+ showToast("success", "Notebook Deleted", actions);
+}
+
export {
showNotesMovedToast,
showNoteDeleted,
showNoteColored,
showUnpinnedToast,
+ showNoteBookDeleted,
};
diff --git a/apps/web/src/components/notebook/index.js b/apps/web/src/components/notebook/index.js
index 498a88b9b..9fe6f5043 100644
--- a/apps/web/src/components/notebook/index.js
+++ b/apps/web/src/components/notebook/index.js
@@ -6,6 +6,7 @@ import * as Icon from "../icons";
import { showEditNoteDialog } from "../dialogs/addnotebookdialog";
import { confirm } from "../dialogs/confirm";
import { showUnpinnedToast } from "../../common/toasts";
+import { showNoteBookDeleted } from "../../common/toasts";
function menuItems(notebook, index) {
return [
@@ -30,7 +31,9 @@ function menuItems(notebook, index) {
"Are you sure you want to delete this notebook?"
).then(async (res) => {
if (res) {
- await store.delete(notebook.id, index);
+ await store
+ .delete(notebook.id, index)
+ .then(showNoteBookDeleted(notebook.id));
}
});
},