Skip to content

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

web: make trash actions multi selectable

Abdullah Attae7f546391733
diff --git a/apps/web/src/common/multi-select.ts b/apps/web/src/common/multi-select.ts
index 86fabff7a..38d4deef7 100644
--- a/apps/web/src/common/multi-select.ts
+++ b/apps/web/src/common/multi-select.ts
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { store as noteStore } from "../stores/note-store";
+import { store as trashStore } from "../stores/trash-store";
import { store as notebookStore } from "../stores/notebook-store";
import { store as attachmentStore } from "../stores/attachment-store";
import { store as reminderStore } from "../stores/reminder-store";
@@ -27,7 +28,11 @@ import { db } from "./db";
import { showToast } from "../utils/toast";
import Vault from "./vault";
import { TaskManager } from "./task-manager";
-import { ConfirmDialog, showMultiDeleteConfirmation } from "../dialogs/confirm";
+import {
+ ConfirmDialog,
+ showMultiDeleteConfirmation,
+ showMultiPermanentDeleteConfirmation
+} from "../dialogs/confirm";
import { strings } from "@notesnook/intl";
async function moveNotesToTrash(ids: string[], confirm = true) {
@@ -77,14 +82,7 @@ async function moveNotebooksToTrash(ids: string[]) {
if (!result) return;
if (result.deleteContainingNotes) {
- await Multiselect.moveNotesToTrash(
- Array.from(
- new Set(
- (await Promise.all(ids.map((id) => db.notebooks.notes(id)))).flat()
- )
- ),
- false
- );
+ await Multiselect.moveNotesToTrash(await db.notebooks.notes(...ids), false);
}
await TaskManager.startTask({
@@ -182,10 +180,50 @@ async function deleteTags(ids: string[]) {
showToast("success", strings.actions.deleted.tag(ids.length));
}
+async function restoreItemsFromTrash(ids: string[]) {
+ if (!ids.length) return;
+
+ await TaskManager.startTask({
+ type: "status",
+ id: "restoreItems",
+ title: strings.inProgressActions.restoring.item(ids.length),
+ action: async (report) => {
+ report({
+ text: strings.inProgressActions.restoring.item(ids.length)
+ });
+ await trashStore.restore(...ids);
+ }
+ });
+
+ showToast("success", strings.actions.restored.item(ids.length));
+}
+
+async function deleteItemsFromTrash(ids: string[]) {
+ if (!ids.length) return;
+
+ if (!(await showMultiPermanentDeleteConfirmation(ids.length))) return;
+
+ await TaskManager.startTask({
+ type: "status",
+ id: "restoreItems",
+ title: strings.inProgressActions.permanentlyDeleting.item(ids.length),
+ action: async (report) => {
+ report({
+ text: strings.inProgressActions.permanentlyDeleting.item(ids.length)
+ });
+ await trashStore.delete(...ids);
+ }
+ });
+
+ showToast("success", strings.actions.permanentlyDeleted.item(ids.length));
+}
+
export const Multiselect = {
moveRemindersToTrash,
moveNotebooksToTrash,
moveNotesToTrash,
deleteAttachments,
- deleteTags
+ deleteTags,
+ restoreItemsFromTrash,
+ deleteItemsFromTrash
};
diff --git a/apps/web/src/components/trash-item/index.tsx b/apps/web/src/components/trash-item/index.tsx
index a4b3b8acd..0a0c33654 100644
--- a/apps/web/src/components/trash-item/index.tsx
+++ b/apps/web/src/components/trash-item/index.tsx
@@ -19,17 +19,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import ListItem from "../list-item";
import { Restore, DeleteForver } from "../icons";
-import { store } from "../../stores/trash-store";
import { Flex, Text } from "@theme-ui/components";
import TimeAgo from "../time-ago";
-import { pluralize, toTitleCase } from "@notesnook/common";
-import { showToast } from "../../utils/toast";
+import { toTitleCase } from "@notesnook/common";
import { MenuItem } from "@notesnook/ui";
import { TrashItem as TrashItemType } from "@notesnook/core";
import { useEditorStore } from "../../stores/editor-store";
-import { showMultiPermanentDeleteConfirmation } from "../../dialogs/confirm";
import { useStore as useSelectionStore } from "../../stores/selection-store";
import { strings } from "@notesnook/intl";
+import { Multiselect } from "../../common/multi-select";
type TrashItemProps = { item: TrashItemType; date: number };
function TrashItem(props: TrashItemProps) {
@@ -44,7 +42,9 @@ function TrashItem(props: TrashItemProps) {
body={item.itemType === "note" ? item.headline : item.description}
onKeyPress={async (e) => {
if (e.key === "Delete") {
- await deleteTrash(useSelectionStore.getState().selectedItems);
+ await Multiselect.deleteItemsFromTrash(
+ useSelectionStore.getState().selectedItems
+ );
}
}}
footer={
@@ -81,9 +81,7 @@ export const trashMenuItems: (
key: "restore",
title: strings.restore(),
icon: Restore.path,
- onClick: async () => {
- await store.restore(...ids);
- },
+ onClick: () => Multiselect.restoreItemsFromTrash(ids),
multiSelect: true
},
{
@@ -92,16 +90,8 @@ export const trashMenuItems: (
title: strings.delete(),
icon: DeleteForver.path,
variant: "dangerous",
- onClick: async () => {
- await deleteTrash(ids);
- },
+ onClick: () => Multiselect.deleteItemsFromTrash(ids),
multiSelect: true
}
];
};
-
-export async function deleteTrash(ids: string[]) {
- if (!(await showMultiPermanentDeleteConfirmation(ids.length))) return;
- await store.delete(...ids);
- showToast("success", `${pluralize(ids.length, "item")} permanently deleted`);
-}
diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.po
index 02204e248..ae567805a 100644
--- a/packages/intl/locale/en.po
+++ b/packages/intl/locale/en.po
@@ -1,17 +1,11 @@
msgid ""
msgstr ""
-"POT-Creation-Date: 2025-06-05 11:43+0500\n"
+"POT-Creation-Date: 2025-06-21 11:05+0500\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: @lingui/cli\n"
"Language: en\n"
-"Project-Id-Version: \n"
-"Report-Msgid-Bugs-To: \n"
-"PO-Revision-Date: \n"
-"Last-Translator: \n"
-"Language-Team: \n"
-"Plural-Forms: \n"
#: src/strings.ts:2410
msgid " \"Notebook > Notes\""
@@ -157,7 +151,7 @@ msgstr "{count, plural, one {Attachment deleted} other {# attachments deleted}}"
msgid "{count, plural, one {Attachment downloaded at {path}} other {#/{total} attachments downloaded as a zip file at {path}}}"
msgstr "{count, plural, one {Attachment downloaded at {path}} other {#/{total} attachments downloaded as a zip file at {path}}}"
-#: generated/actions.ts:210
+#: generated/actions.ts:216
msgid "{count, plural, one {Color renamed} other {# colors renamed}}"
msgstr "{count, plural, one {Color renamed} other {# colors renamed}}"
@@ -250,7 +244,7 @@ msgstr "{count, plural, one {Item could not be published} other {# items could n
msgid "{count, plural, one {Item could not be unpublished} other {# items could not be unpublished}}"
msgstr "{count, plural, one {Item could not be unpublished} other {# items could not be unpublished}}"
-#: generated/actions.ts:202
+#: generated/actions.ts:208
msgid "{count, plural, one {Item created} other {# items created}}"
msgstr "{count, plural, one {Item created} other {# items created}}"
@@ -258,7 +252,7 @@ msgstr "{count, plural, one {Item created} other {# items created}}"
msgid "{count, plural, one {Item deleted} other {# items deleted}}"
msgstr "{count, plural, one {Item deleted} other {# items deleted}}"
-#: generated/actions.ts:173
+#: generated/actions.ts:179
msgid "{count, plural, one {Item edited} other {# items edited}}"
msgstr "{count, plural, one {Item edited} other {# items edited}}"
@@ -266,24 +260,25 @@ msgstr "{count, plural, one {Item edited} other {# items edited}}"
msgid "{count, plural, one {Item moved to trash} other {# items moved to trash}}"
msgstr "{count, plural, one {Item moved to trash} other {# items moved to trash}}"
-#: generated/actions.ts:87
+#: generated/actions.ts:80
+#: generated/actions.ts:93
msgid "{count, plural, one {Item permanently deleted} other {# items permanently deleted}}"
msgstr "{count, plural, one {Item permanently deleted} other {# items permanently deleted}}"
-#: generated/actions.ts:104
+#: generated/actions.ts:110
msgid "{count, plural, one {Item published} other {# items published}}"
msgstr "{count, plural, one {Item published} other {# items published}}"
-#: generated/actions.ts:219
+#: generated/actions.ts:225
msgid "{count, plural, one {Item renamed} other {# items renamed}}"
msgstr "{count, plural, one {Item renamed} other {# items renamed}}"
-#: generated/actions.ts:137
-#: generated/actions.ts:150
+#: generated/actions.ts:143
+#: generated/actions.ts:156
msgid "{count, plural, one {Item restored} other {# items restored}}"
msgstr "{count, plural, one {Item restored} other {# items restored}}"
-#: generated/actions.ts:121
+#: generated/actions.ts:127
msgid "{count, plural, one {Item unpublished} other {# items unpublished}}"
msgstr "{count, plural, one {Item unpublished} other {# items unpublished}}"
@@ -323,15 +318,15 @@ msgstr "{count, plural, one {Note moved to trash} other {# notes moved to trash}
msgid "{count, plural, one {Note permanently deleted} other {# notes permanently deleted}}"
msgstr "{count, plural, one {Note permanently deleted} other {# notes permanently deleted}}"
-#: generated/actions.ts:95
+#: generated/actions.ts:101
msgid "{count, plural, one {Note published} other {# notes published}}"
msgstr "{count, plural, one {Note published} other {# notes published}}"
-#: generated/actions.ts:129
+#: generated/actions.ts:135
msgid "{count, plural, one {Note restored} other {# notes restored}}"
msgstr "{count, plural, one {Note restored} other {# notes restored}}"
-#: generated/actions.ts:112
+#: generated/actions.ts:118
msgid "{count, plural, one {Note unpublished} other {# notes unpublished}}"
msgstr "{count, plural, one {Note unpublished} other {# notes unpublished}}"
@@ -339,7 +334,7 @@ msgstr "{count, plural, one {Note unpublished} other {# notes unpublished}}"
msgid "{count, plural, one {Note will be automatically deleted from all other devices & any future changes won't get synced. Are you sure you want to continue?} other {# notes will be automatically deleted from all other devices & any future changes won't get synced. Are you sure you want to continue?}}"
msgstr "{count, plural, one {Note will be automatically deleted from all other devices & any future changes won't get synced. Are you sure you want to continue?} other {# notes will be automatically deleted from all other devices & any future changes won't get synced. Are you sure you want to continue?}}"
-#: generated/actions.ts:181
+#: generated/actions.ts:187
msgid "{count, plural, one {Notebook created} other {# notebooks created}}"
msgstr "{count, plural, one {Notebook created} other {# notebooks created}}"
@@ -347,7 +342,7 @@ msgstr "{count, plural, one {Notebook created} other {# notebooks created}}"
msgid "{count, plural, one {Notebook deleted} other {# notebooks deleted}}"
msgstr "{count, plural, one {Notebook deleted} other {# notebooks deleted}}"
-#: generated/actions.ts:162
+#: generated/actions.ts:168
msgid "{count, plural, one {Notebook edited} other {# notebooks edited}}"
msgstr "{count, plural, one {Notebook edited} other {# notebooks edited}}"
@@ -359,7 +354,7 @@ msgstr "{count, plural, one {Notebook moved to trash} other {# notebooks moved t
msgid "{count, plural, one {Notebook permanently deleted} other {# notebooks permanently deleted}}"
msgstr "{count, plural, one {Notebook permanently deleted} other {# notebooks permanently deleted}}"
-#: generated/actions.ts:133
+#: generated/actions.ts:139
msgid "{count, plural, one {Notebook restored} other {# notebooks restored}}"
msgstr "{count, plural, one {Notebook restored} other {# notebooks restored}}"
@@ -372,6 +367,11 @@ msgstr "{count, plural, one {Permanently delete attachment} other {Permanently d
msgid "{count, plural, one {Permanently delete item} other {Permanently delete # items}}"
msgstr "{count, plural, one {Permanently delete item} other {Permanently delete # items}}"
+#: generated/in-progress-actions.ts:66
+#: generated/in-progress-actions.ts:75
+msgid "{count, plural, one {permanently deleting item...} other {permanently deleting # items...}}"
+msgstr "{count, plural, one {permanently deleting item...} other {permanently deleting # items...}}"
+
#: generated/do-actions.ts:99
msgid "{count, plural, one {Pin item} other {Pin # items}}"
msgstr "{count, plural, one {Pin item} other {Pin # items}}"
@@ -444,11 +444,16 @@ msgstr "{count, plural, one {Restore note} other {Restore # notes}}"
msgid "{count, plural, one {Restore notebook} other {Restore # notebooks}}"
msgstr "{count, plural, one {Restore notebook} other {Restore # notebooks}}"
-#: generated/actions.ts:189
+#: generated/in-progress-actions.ts:49
+#: generated/in-progress-actions.ts:58
+msgid "{count, plural, one {Restoring item...} other {Restoring # items...}}"
+msgstr "{count, plural, one {Restoring item...} other {Restoring # items...}}"
+
+#: generated/actions.ts:195
msgid "{count, plural, one {Shortcut created} other {# shortcuts created}}"
msgstr "{count, plural, one {Shortcut created} other {# shortcuts created}}"
-#: generated/actions.ts:185
+#: generated/actions.ts:191
msgid "{count, plural, one {Tag created} other {# tags created}}"
msgstr "{count, plural, one {Tag created} other {# tags created}}"
@@ -456,7 +461,7 @@ msgstr "{count, plural, one {Tag created} other {# tags created}}"
msgid "{count, plural, one {Tag deleted} other {# tags deleted}}"
msgstr "{count, plural, one {Tag deleted} other {# tags deleted}}"
-#: generated/actions.ts:158
+#: generated/actions.ts:164
msgid "{count, plural, one {Tag edited} other {# tags edited}}"
msgstr "{count, plural, one {Tag edited} other {# tags edited}}"
@@ -613,8 +618,8 @@ msgid "A to Z"
msgstr "A to Z"
#: src/strings.ts:447
-msgid "A vault stores your notes in a encrypted storage."
-msgstr "A vault stores your notes in a encrypted storage."
+msgid "A vault stores your notes in an encrypted storage."
+msgstr "A vault stores your notes in an encrypted storage."
#: src/strings.ts:661
msgid "Abc"
diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.po
index 7ddf3f131..e464c9dfb 100644
--- a/packages/intl/locale/pseudo-LOCALE.po
+++ b/packages/intl/locale/pseudo-LOCALE.po
@@ -1,17 +1,11 @@
msgid ""
msgstr ""
-"POT-Creation-Date: 2025-06-05 11:43+0500\n"
+"POT-Creation-Date: 2025-06-21 11:05+0500\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: @lingui/cli\n"
"Language: pseudo-LOCALE\n"
-"Project-Id-Version: \n"
-"Report-Msgid-Bugs-To: \n"
-"PO-Revision-Date: \n"
-"Last-Translator: \n"
-"Language-Team: \n"
-"Plural-Forms: \n"
#: src/strings.ts:2410
msgid " \"Notebook > Notes\""
@@ -157,7 +151,7 @@ msgstr ""
msgid "{count, plural, one {Attachment downloaded at {path}} other {#/{total} attachments downloaded as a zip file at {path}}}"
msgstr ""
-#: generated/actions.ts:210
+#: generated/actions.ts:216
msgid "{count, plural, one {Color renamed} other {# colors renamed}}"
msgstr ""
@@ -250,7 +244,7 @@ msgstr ""
msgid "{count, plural, one {Item could not be unpublished} other {# items could not be unpublished}}"
msgstr ""
-#: generated/actions.ts:202
+#: generated/actions.ts:208
msgid "{count, plural, one {Item created} other {# items created}}"
msgstr ""
@@ -258,7 +252,7 @@ msgstr ""
msgid "{count, plural, one {Item deleted} other {# items deleted}}"
msgstr ""
-#: generated/actions.ts:173
+#: generated/actions.ts:179
msgid "{count, plural, one {Item edited} other {# items edited}}"
msgstr ""
@@ -266,24 +260,25 @@ msgstr ""
msgid "{count, plural, one {Item moved to trash} other {# items moved to trash}}"
msgstr ""
-#: generated/actions.ts:87
+#: generated/actions.ts:80
+#: generated/actions.ts:93
msgid "{count, plural, one {Item permanently deleted} other {# items permanently deleted}}"
msgstr ""
-#: generated/actions.ts:104
+#: generated/actions.ts:110
msgid "{count, plural, one {Item published} other {# items published}}"
msgstr ""
-#: generated/actions.ts:219
+#: generated/actions.ts:225
msgid "{count, plural, one {Item renamed} other {# items renamed}}"
msgstr ""
-#: generated/actions.ts:137
-#: generated/actions.ts:150
+#: generated/actions.ts:143
+#: generated/actions.ts:156
msgid "{count, plural, one {Item restored} other {# items restored}}"
msgstr ""
-#: generated/actions.ts:121
+#: generated/actions.ts:127
msgid "{count, plural, one {Item unpublished} other {# items unpublished}}"
msgstr ""
@@ -323,15 +318,15 @@ msgstr ""
msgid "{count, plural, one {Note permanently deleted} other {# notes permanently deleted}}"
msgstr ""
-#: generated/actions.ts:95
+#: generated/actions.ts:101
msgid "{count, plural, one {Note published} other {# notes published}}"
msgstr ""
-#: generated/actions.ts:129
+#: generated/actions.ts:135
msgid "{count, plural, one {Note restored} other {# notes restored}}"
msgstr ""
-#: generated/actions.ts:112
+#: generated/actions.ts:118
msgid "{count, plural, one {Note unpublished} other {# notes unpublished}}"
msgstr ""
@@ -339,7 +334,7 @@ msgstr ""
msgid "{count, plural, one {Note will be automatically deleted from all other devices & any future changes won't get synced. Are you sure you want to continue?} other {# notes will be automatically deleted from all other devices & any future changes won't get synced. Are you sure you want to continue?}}"
msgstr ""
-#: generated/actions.ts:181
+#: generated/actions.ts:187
msgid "{count, plural, one {Notebook created} other {# notebooks created}}"
msgstr ""
@@ -347,7 +342,7 @@ msgstr ""
msgid "{count, plural, one {Notebook deleted} other {# notebooks deleted}}"
msgstr ""
-#: generated/actions.ts:162
+#: generated/actions.ts:168
msgid "{count, plural, one {Notebook edited} other {# notebooks edited}}"
msgstr ""
@@ -359,7 +354,7 @@ msgstr ""
msgid "{count, plural, one {Notebook permanently deleted} other {# notebooks permanently deleted}}"
msgstr ""
-#: generated/actions.ts:133
+#: generated/actions.ts:139
msgid "{count, plural, one {Notebook restored} other {# notebooks restored}}"
msgstr ""
@@ -372,6 +367,11 @@ msgstr ""
msgid "{count, plural, one {Permanently delete item} other {Permanently delete # items}}"
msgstr ""
+#: generated/in-progress-actions.ts:66
+#: generated/in-progress-actions.ts:75
+msgid "{count, plural, one {permanently deleting item...} other {permanently deleting # items...}}"
+msgstr ""
+
#: generated/do-actions.ts:99
msgid "{count, plural, one {Pin item} other {Pin # items}}"
msgstr ""
@@ -444,11 +444,16 @@ msgstr ""
msgid "{count, plural, one {Restore notebook} other {Restore # notebooks}}"
msgstr ""
-#: generated/actions.ts:189
+#: generated/in-progress-actions.ts:49
+#: generated/in-progress-actions.ts:58
+msgid "{count, plural, one {Restoring item...} other {Restoring # items...}}"
+msgstr ""
+
+#: generated/actions.ts:195
msgid "{count, plural, one {Shortcut created} other {# shortcuts created}}"
msgstr ""
-#: generated/actions.ts:185
+#: generated/actions.ts:191
msgid "{count, plural, one {Tag created} other {# tags created}}"
msgstr ""
@@ -456,7 +461,7 @@ msgstr ""
msgid "{count, plural, one {Tag deleted} other {# tags deleted}}"
msgstr ""
-#: generated/actions.ts:158
+#: generated/actions.ts:164
msgid "{count, plural, one {Tag edited} other {# tags edited}}"
msgstr ""
@@ -613,7 +618,7 @@ msgid "A to Z"
msgstr ""
#: src/strings.ts:447
-msgid "A vault stores your notes in a encrypted storage."
+msgid "A vault stores your notes in an encrypted storage."
msgstr ""
#: src/strings.ts:661
diff --git a/packages/intl/scripts/generate-strings.mjs b/packages/intl/scripts/generate-strings.mjs
index f47938807..2c908db83 100644
--- a/packages/intl/scripts/generate-strings.mjs
+++ b/packages/intl/scripts/generate-strings.mjs
@@ -83,7 +83,7 @@ const ACTIONS = [
{
action: "permanentlyDeleted",
label: "permanently deleted",
- dataTypes: ["note", "notebook"]
+ dataTypes: ["note", "notebook", "item"]
},
{ action: "published", label: "published", dataTypes: ["note"] },
{ action: "unpublished", label: "unpublished", dataTypes: ["note"] },
@@ -121,7 +121,7 @@ const ACTION_CONFIRMATIONS = [
"tag",
"color",
"attachment"
- ]
+ ],
},
{
action: "permanentlyDelete",
@@ -148,6 +148,16 @@ const IN_PROGRESS_ACTIONS = [
action: "deleting",
label: "Deleting",
dataTypes: ["note", "notebook", "attachment", "tag", "reminder"]
+ },
+ {
+ action: "restoring",
+ label: "Restoring",
+ dataTypes: ["item"]
+ },
+ {
+ action: "permanentlyDeleting",
+ label: "permanently deleting",
+ dataTypes: ["item"]
}
];