Skip to content

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

web: improve toast shown to basic users on using pro features

Abdullah Atta35a2e11afd13
diff --git a/apps/web/src/app-effects.tsx b/apps/web/src/app-effects.tsx
index 87f5f2ac8..68498a54f 100644
--- a/apps/web/src/app-effects.tsx
+++ b/apps/web/src/app-effects.tsx
@@ -31,7 +31,7 @@ import {
import { introduceFeatures, showUpgradeReminderDialogs } from "./common";
import { AppEventManager, AppEvents } from "./common/app-events";
import { db } from "./common/db";
-import { EV, EVENTS } from "@notesnook/core/dist/common";
+import { CHECK_IDS, EV, EVENTS } from "@notesnook/core/dist/common";
import { registerKeyMap } from "./common/key-map";
import { isUserPremium } from "./hooks/use-is-user-premium";
import { updateStatus, removeStatus, getStatus } from "./hooks/use-status";
@@ -70,11 +70,27 @@ export default function AppEffects({ setShow }: AppEffectsProps) {
if (isUserPremium()) {
return { type, result: true };
} else {
- showToast(
- "error",
- "Please upgrade your account to Pro to use this feature.",
- [{ text: "Upgrade now", onClick: () => BuyDialog.show({}) }]
- );
+ let sentence = "Please upgrade your account to Pro ";
+ switch (type) {
+ case CHECK_IDS.noteColor:
+ sentence += "to add colors.";
+ break;
+ case CHECK_IDS.noteTag:
+ sentence += "to add more tags.";
+ break;
+ case CHECK_IDS.notebookAdd:
+ sentence += "to add more notebooks.";
+ break;
+ case CHECK_IDS.vaultAdd:
+ sentence += "to use the notes vault.";
+ break;
+ default:
+ sentence += "to use this feature.";
+ break;
+ }
+ showToast("error", sentence, [
+ { text: "Upgrade now", onClick: () => BuyDialog.show({}) }
+ ]);
return { type, result: false };
}
}
diff --git a/apps/web/src/dialogs/create-color-dialog.tsx b/apps/web/src/dialogs/create-color-dialog.tsx
index 84e34456f..c628db774 100644
--- a/apps/web/src/dialogs/create-color-dialog.tsx
+++ b/apps/web/src/dialogs/create-color-dialog.tsx
@@ -63,7 +63,7 @@ export const CreateColorDialog = DialogManager.register(
colorCode: form.color,
title: form.title
});
- props.onClose(colorId);
+ props.onClose(colorId || false);
}}
>
<Field
diff --git a/apps/web/src/dialogs/item-dialog.tsx b/apps/web/src/dialogs/item-dialog.tsx
index c0c6a1675..73a756b8c 100644
--- a/apps/web/src/dialogs/item-dialog.tsx
+++ b/apps/web/src/dialogs/item-dialog.tsx
@@ -93,8 +93,8 @@ export const CreateTagDialog = {
title: "Create tag",
subtitle: "You can create as many tags as you want."
}).then(async (title) => {
- if (!title) return;
- await db.tags.add({ title });
+ if (!title || !(await db.tags.add({ title }))) return;
+
showToast("success", "Tag created!");
useTagStore.getState().refresh();
})