mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
fix: permanent delete not working
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user