A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: no need to show confirm dialogs before moving to trash
thecodrr7dd430f6be07
diff --git a/apps/web/src/common/selectionoptions.js b/apps/web/src/common/selectionoptions.jsindex da767d35c..8600fe331 100644--- a/apps/web/src/common/selectionoptions.js+++ b/apps/web/src/common/selectionoptions.js@@ -6,7 +6,7 @@ import { store as editorStore } from "../stores/editor-store";import { store as trashStore } from "../stores/trash-store";import { db } from "./index";import { showMoveNoteDialog } from "../components/dialogs/movenotedialog";-import { showDeleteConfirmation } from "../components/dialogs/confirm";+import { showMultiDeleteConfirmation } from "../components/dialogs/confirm";import { showExportDialog } from "../components/dialogs/exportdialog";import { showToast } from "../utils/toast";@@ -31,7 +31,7 @@ const DeleteOption = createOption(async function (state) {const item = state.selectedItems[0];- if (!(await showDeleteConfirmation(item.type, true))) return;+ if (!(await showMultiDeleteConfirmation(item.type))) return;var isAnyNoteOpened = false;const items = state.selectedItems.map((item) => {diff --git a/apps/web/src/components/dialogs/confirm.js b/apps/web/src/components/dialogs/confirm.jsindex 837206f2c..b5ce59b17 100644--- a/apps/web/src/components/dialogs/confirm.js+++ b/apps/web/src/components/dialogs/confirm.js@@ -49,33 +49,6 @@ export function confirm());}-/**- *- * @param {"note"|"notebook"} type- */-export function showDeleteConfirmation(type, multi = false) {- let noun = type === "note" ? "Note" : "Notebook";- if (multi) noun += "s";- let lowerCaseNoun = noun.toLowerCase();-- let secondPronoun = multi ? "they" : "it";-- return confirm(Icon.Trash, {- title: `Delete ${noun}?`,- message: (- <Text as="span" fontSize="body">- The {lowerCaseNoun} will be{" "}- <Text as="span" color="primary">- kept in your Trash for 7 days- </Text>{" "}- after which {secondPronoun} will be permanently removed.- </Text>- ),- yesText: `Delete ${lowerCaseNoun}`,- noText: "Cancel",- });-}-export function showMultiDeleteConfirmation(type) {let noun = type === "note" ? "Notes" : "Notebooks";diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.jsindex 075ea3d4a..b7bb0f9b2 100644--- a/apps/web/src/components/note/index.js+++ b/apps/web/src/components/note/index.js@@ -3,7 +3,6 @@ import { Flex, Text } from "rebass";import * as Icon from "../icons";import TimeAgo from "timeago-react";import ListItem from "../list-item";-import { confirm, showDeleteConfirmation } from "../dialogs/confirm";import { showMoveNoteDialog } from "../dialogs/movenotedialog";import { store, useStore } from "../../stores/note-store";import { showPasswordDialog } from "../dialogs/passworddialog";@@ -68,33 +67,12 @@ function menuItems(note, context) {visible: context?.type === "topic",title: "Remove from topic",onClick: async () => {- confirm(Icon.Topic, {- title: "Remove Note from Topic",- subtitle: "Are you sure you want to remove the note from this topic?",- yesText: "Remove note",- noText: "Cancel",- message: (- <Text as="span">- <Text as="span" color="primary">- This action does not delete the note.- </Text>{" "}- The note will only be removed from this notebook. You will still- be able to{" "}- <Text as="span" color="primary">- access it from Home and other places.- </Text>- </Text>- ),- }).then(async (res) => {- if (res) {- console.log(context);- await db.notebooks- .notebook(context.value.id)- .topics.topic(context.value.topic)- .delete(note.id);- store.setContext(context);- }- });+ await db.notebooks+ .notebook(context.value.id)+ .topics.topic(context.value.topic)+ .delete(note.id);+ store.setContext(context);+ await showToast("success", "Note removed from topic!");},},{@@ -110,11 +88,7 @@ function menuItems(note, context) {});if (!res) return;}- showDeleteConfirmation("note").then(async (res) => {- if (res) {- await store.delete(note.id).then(() => showItemDeletedToast(note));- }- });+ await store.delete(note.id).then(() => showItemDeletedToast(note));},},];diff --git a/apps/web/src/components/notebook/index.js b/apps/web/src/components/notebook/index.jsindex 2bfebc97a..407a8e348 100644--- a/apps/web/src/components/notebook/index.js+++ b/apps/web/src/components/notebook/index.js@@ -3,7 +3,6 @@ import { Flex, Text } from "rebass";import ListItem from "../list-item";import { store } from "../../stores/notebook-store";import { store as appStore } from "../../stores/app-store";-import { showDeleteConfirmation } from "../dialogs/confirm";import { showItemDeletedToast, showUnpinnedToast } from "../../common/toasts";import { db } from "../../common";import * as Icon from "../icons";@@ -33,14 +32,10 @@ function menuItems(notebook, index) {{title: "Move to trash",color: "red",- onClick: () => {- showDeleteConfirmation("notebook").then(async (res) => {- if (res) {- await store- .delete(notebook.id, index)- .then(() => showItemDeletedToast(notebook));- }- });+ onClick: async () => {+ await store+ .delete(notebook.id, index)+ .then(() => showItemDeletedToast(notebook));},},];diff --git a/apps/web/src/components/topic/index.js b/apps/web/src/components/topic/index.jsindex 05d952d81..577e5ac8c 100644--- a/apps/web/src/components/topic/index.js+++ b/apps/web/src/components/topic/index.js@@ -1,11 +1,8 @@import React from "react";import ListItem from "../list-item";-import { confirm } from "../dialogs/confirm";-import * as Icon from "../icons";import { db } from "../../common";import { store } from "../../stores/notebook-store";import { store as appStore } from "../../stores/app-store";-import { Text } from "rebass";import { hashNavigate } from "../../navigation";const menuItems = (item) => [@@ -25,30 +22,9 @@ const menuItems = (item) => [title: "Delete",visible: item.title !== "General",color: "red",- onClick: () => {- confirm(Icon.Trash, {- title: "Delete topic",- subtitle: "Are you sure you want to delete this topic?",- yesText: "Delete topic",- noText: "Cancel",- message: (- <>- This action is{" "}- <Text as="span" color="error">- IRREVERSIBLE- </Text>- . Deleting this topic{" "}- <Text as="span" color="primary">- will not delete the notes contained in it.- </Text>- </>- ),- }).then(async (res) => {- if (res) {- await db.notebooks.notebook(item.notebookId).topics.delete(item.id);- store.setSelectedNotebookTopics(item.notebookId);- }- });+ onClick: async () => {+ await db.notebooks.notebook(item.notebookId).topics.delete(item.id);+ store.setSelectedNotebookTopics(item.notebookId);},},];