Skip to content

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

refactor: cleanup confirm dialog

thecodrr20e75b353499
diff --git a/apps/web/src/common/dialogcontroller.js b/apps/web/src/common/dialogcontroller.js
index 63eefa43a..606805664 100644
--- a/apps/web/src/common/dialogcontroller.js
+++ b/apps/web/src/common/dialogcontroller.js
@@ -100,10 +100,14 @@ export function showBuyDialog(plan, couponCode) {
));
}
-export function confirm(
- icon,
- { title, subtitle, message, yesText, noText, yesAction }
-) {
+export function confirm({
+ title,
+ subtitle,
+ message,
+ yesText,
+ noText,
+ yesAction,
+}) {
return showDialog((Dialogs, perform) => (
<Dialogs.Confirm
title={title}
@@ -111,7 +115,6 @@ export function confirm(
message={message}
yesText={yesText}
noText={noText}
- icon={icon}
onNo={() => perform(false)}
onYes={() => {
if (yesAction) yesAction();
@@ -121,8 +124,8 @@ export function confirm(
));
}
-export function showMultiDeleteConfirmation(length, permanentDelete) {
- return confirm(Icon.Trash, {
+export function showMultiDeleteConfirmation(length) {
+ return confirm({
title: `Delete ${length} items?`,
message: (
<Text as="span">
@@ -139,7 +142,7 @@ export function showMultiDeleteConfirmation(length, permanentDelete) {
}
export function showMultiPermanentDeleteConfirmation(length) {
- return confirm(Icon.Trash, {
+ return confirm({
title: `Permanently delete ${length} items?`,
message: (
<Text as="span">
@@ -157,7 +160,7 @@ export function showMultiPermanentDeleteConfirmation(length) {
}
export function showLogoutConfirmation() {
- return confirm(Icon.Logout, {
+ return confirm({
title: `Logout?`,
message:
"Logging out will delete all local data and reset the app. Make sure you have synced your data before logging out.",
@@ -185,7 +188,7 @@ export function showLogoutConfirmation() {
// }
export function showAccountLoggedOutNotice(reason) {
- return confirm(Icon.Logout, {
+ return confirm({
title: reason,
message: `You were logged out`,
yesText: `Okay`,
@@ -193,7 +196,7 @@ export function showAccountLoggedOutNotice(reason) {
}
export function showAppUpdatedNotice(version) {
- return confirm(Icon.Update, {
+ return confirm({
title: `Welcome to v${version.formatted}`,
message: (
<Flex
@@ -219,7 +222,7 @@ export function showAppUpdatedNotice(version) {
}
export function showAppAvailableNotice(version) {
- return confirm(Icon.Update, {
+ return confirm({
title: `New version available`,
message: (
<Flex
diff --git a/apps/web/src/components/trash-item/index.js b/apps/web/src/components/trash-item/index.js
index eb2479f9a..18c33139e 100644
--- a/apps/web/src/components/trash-item/index.js
+++ b/apps/web/src/components/trash-item/index.js
@@ -51,7 +51,7 @@ const menuItems = [
icon: Icon.DeleteForver,
color: "red",
onClick: ({ item }) => {
- confirm(Icon.Trash, {
+ confirm({
title: `Permanently Delete ${toTitleCase(item.itemType)}`,
subtitle: `Are you sure you want to permanently delete this ${item.itemType}?`,
yesText: `Delete ${item.itemType}`,
diff --git a/apps/web/src/views/settings.js b/apps/web/src/views/settings.js
index 969cb288a..056dcdb65 100644
--- a/apps/web/src/views/settings.js
+++ b/apps/web/src/views/settings.js
@@ -443,7 +443,7 @@ function Settings(props) {
"3. We send an event when you open the checkout to buy Notesnook Pro.",
"4. We send an event when you claim an offer or promo.",
];
- confirm(null, {
+ confirm({
title: "Telemetry details",
subtitle:
"Read details of all the usage data we collect and send to our servers.",
diff --git a/apps/web/src/views/trash.js b/apps/web/src/views/trash.js
index 7d8e2b962..6058cfb86 100644
--- a/apps/web/src/views/trash.js
+++ b/apps/web/src/views/trash.js
@@ -27,7 +27,7 @@ function Trash() {
content: "Clear Trash",
icon: Icon.Trash,
onClick: function () {
- confirm(Icon.Trash, {
+ confirm({
title: "Clear Trash",
subtitle: "Are you sure you want to clear all the trash?",
yesText: "Clear trash",