Skip to content

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

fix: permanent delete not working

thecodrrf449fb6c33ac
diff --git a/apps/web/src/common/toasts.js b/apps/web/src/common/toasts.js
index 69e96280d..a69608b6c 100644
--- a/apps/web/src/common/toasts.js
+++ b/apps/web/src/common/toasts.js
@@ -1,7 +1,6 @@
import { db } from "./db";
import { store as notestore } from "../stores/note-store";
import { store as nbstore } from "../stores/notebook-store";
-import { store as trashstore } from "../stores/trash-store";
import { showToast } from "../utils/toast";
function showNotesMovedToast(note, noteIds, notebook) {
@@ -57,12 +56,13 @@ function showItemDeletedToast(item) {
var toast = showToast("success", messageText, actions);
}
-async function showUndoableToast(message, onAction, onUndo) {
- const timeoutId = setTimeout(onAction, 5000);
+async function showUndoableToast(message, onAction, onPermanentAction, onUndo) {
+ await onAction();
+ const timeoutId = setTimeout(onPermanentAction, 5000);
const undoAction = async () => {
+ clearTimeout(timeoutId);
toast.hide();
onUndo();
- clearTimeout(timeoutId);
};
let actions = [{ text: "Undo", onClick: undoAction }];
var toast = showToast("success", message, actions);
diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.js
index 76d5700d1..6dfd2569a 100644
--- a/apps/web/src/components/note/index.js
+++ b/apps/web/src/components/note/index.js
@@ -318,8 +318,8 @@ const menuItems = [
{
key: "movetotrash",
title: "Move to trash",
- color: "red",
- iconColor: "red",
+ color: "error",
+ iconColor: "error",
icon: Icon.Trash,
disabled: ({ items }) =>
items.length === 1 && db.monographs.isPublished(items[0].id),
@@ -337,8 +337,8 @@ const topicNoteMenuItems = [
key: "removefromtopic",
title: "Remove from topic",
icon: Icon.TopicRemove,
- color: "red",
- iconColor: "red",
+ color: "error",
+ iconColor: "error",
onClick: async ({ items, context }) => {
await db.notebooks
.notebook(context.value.id)
diff --git a/apps/web/src/components/notebook/index.js b/apps/web/src/components/notebook/index.js
index f50ba62d2..415fbe381 100644
--- a/apps/web/src/components/notebook/index.js
+++ b/apps/web/src/components/notebook/index.js
@@ -124,8 +124,8 @@ const menuItems = [
},
{
title: "Move to trash",
- color: "red",
- iconColor: "red",
+ color: "error",
+ iconColor: "error",
icon: Icon.Trash,
onClick: async ({ items }) => {
await Multiselect.moveNotebooksToTrash(items);
diff --git a/apps/web/src/components/trash-item/index.js b/apps/web/src/components/trash-item/index.js
index b26d18b25..64d8fabec 100644
--- a/apps/web/src/components/trash-item/index.js
+++ b/apps/web/src/components/trash-item/index.js
@@ -1,9 +1,6 @@
import React from "react";
import ListItem from "../list-item";
-import {
- confirm,
- showMultiPermanentDeleteConfirmation,
-} from "../../common/dialog-controller";
+import { showMultiPermanentDeleteConfirmation } from "../../common/dialog-controller";
import * as Icon from "../icons";
import { store } from "../../stores/trash-store";
import { Flex, Text } from "rebass";
@@ -48,14 +45,16 @@ const menuItems = [
{
title: "Delete",
icon: Icon.DeleteForver,
- color: "red",
+ color: "error",
+ iconColor: "error",
onClick: async ({ items }) => {
if (!(await showMultiPermanentDeleteConfirmation(items.length))) return;
const ids = items.map((i) => i.id);
showUndoableToast(
`${items.length} items permanently deleted`,
() => store.delete(ids),
- () => store.delete(ids, true)
+ () => store.delete(ids, true),
+ () => store.refresh()
);
},
multiSelect: true,