Skip to content

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

mobile: do not ask for password on vault deletion if user not logged in

Ammar Ahmed4f884a84116f
diff --git a/apps/mobile/app/components/dialogs/vault/index.tsx b/apps/mobile/app/components/dialogs/vault/index.tsx
index 57266e2d3..d7d096087 100644
--- a/apps/mobile/app/components/dialogs/vault/index.tsx
+++ b/apps/mobile/app/components/dialogs/vault/index.tsx
@@ -66,12 +66,14 @@ import {
VAULT_ERRORS
} from "@notesnook/core";
import { useThemeColors } from "@notesnook/theme";
+import { useUserStore } from "../../../stores/use-user-store";
export const VaultDialog: React.FC = () => {
const { colors } = useThemeColors();
// UI State
const [visible, setVisible] = useState(false);
+ const isUserLoggedIn = useUserStore((state) => !!state.user);
const [loading, setLoading] = useState(false);
const [deleteAll, setDeleteAll] = useState(false);
const [biometricUnlock, setBiometricUnlock] = useState(false);
@@ -196,9 +198,12 @@ export const VaultDialog: React.FC = () => {
}
eSendEvent("vaultUpdated");
setLoading(false);
- setTimeout(() => {
- close();
- }, 100);
+ close();
+ ToastManager.show({
+ message: strings.vaultDeleted(),
+ type: "success",
+ context: "global"
+ });
} else {
setLoading(false);
formRef.current.setError("password", strings.passwordIncorrect());
@@ -489,6 +494,13 @@ export const VaultDialog: React.FC = () => {
const { password, newPassword } = formRef.current.getValues();
+ if (requestType === VaultRequestType.DeleteVault && !isUserLoggedIn) {
+ setLoading(true);
+ await deleteVault();
+ setLoading(false);
+ return;
+ }
+
if (requestType === VaultRequestType.CreateVault) {
createVault();
} else if (requestType === VaultRequestType.ChangePassword) {
@@ -700,7 +712,6 @@ export const VaultDialog: React.FC = () => {
icon="shield"
padding={12}
/>
- <Seperator half />
<View
style={{
@@ -709,8 +720,7 @@ export const VaultDialog: React.FC = () => {
>
{(isChangePassword ||
isClearVault ||
- !isCreateVault ||
- isDeleteVault ||
+ (isDeleteVault && isUserLoggedIn) ||
isCustomAction) &&
!isRevokeFingerprint ? (
<>
diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.po
index 8abcecd03..13ef67ae0 100644
--- a/packages/intl/locale/en.po
+++ b/packages/intl/locale/en.po
@@ -2209,8 +2209,8 @@ msgid "Delete mode"
msgstr "Delete mode"
#: src/strings.ts:562
-msgid "Delete notes in this vault"
-msgstr "Delete notes in this vault"
+msgid "Delete notes in this vault permanently"
+msgstr "Delete notes in this vault permanently"
#: src/strings.ts:569
msgid "Delete permanently"
diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.po
index 1c6b1e689..c99b379f2 100644
--- a/packages/intl/locale/pseudo-LOCALE.po
+++ b/packages/intl/locale/pseudo-LOCALE.po
@@ -2198,7 +2198,7 @@ msgid "Delete mode"
msgstr ""
#: src/strings.ts:562
-msgid "Delete notes in this vault"
+msgid "Delete notes in this vault permanently"
msgstr ""
#: src/strings.ts:569
diff --git a/packages/intl/src/strings.ts b/packages/intl/src/strings.ts
index 9e6a052e6..cc7020bdd 100644
--- a/packages/intl/src/strings.ts
+++ b/packages/intl/src/strings.ts
@@ -559,7 +559,7 @@ $day$: Current day (eg. Monday)`,
couldNotUnlock: () => t`Could not unlock`,
unlockNoteDesc: () =>
t`Your note will be unencrypted and removed from the vault.`,
- deleteAllNotes: () => t`Delete notes in this vault`,
+ deleteAllNotes: () => t`Delete notes in this vault permanently`,
getStarted: () => t`Get started`,
saveACopy: () => t`Save a copy`,
discard: () => t`Discard`,