Skip to content

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

fix: delete note from vault before removing

thecodrr6efb234d9001
diff --git a/apps/web/src/common/vault.js b/apps/web/src/common/vault.js
index ef9c613f9..b8bf44a3f 100644
--- a/apps/web/src/common/vault.js
+++ b/apps/web/src/common/vault.js
@@ -63,8 +63,8 @@ class Vault {
.remove(id, password)
.then(() => true)
.catch((e) => {
- if (e.message === db.vault.ERRORS.wrongPassword) return false;
- else console.error(e);
+ console.error(e);
+ return false;
});
}).then(resolve);
});
diff --git a/apps/web/src/components/dialogs/password-dialog.js b/apps/web/src/components/dialogs/password-dialog.js
index 12b38c08f..edc29be1e 100644
--- a/apps/web/src/components/dialogs/password-dialog.js
+++ b/apps/web/src/components/dialogs/password-dialog.js
@@ -18,6 +18,7 @@ function PasswordDialog(props) {
setIsLoading(true);
setError(false);
try {
+ console.log(data);
if (await props.validate(data)) {
props.onDone();
} else {
@@ -25,7 +26,6 @@ function PasswordDialog(props) {
}
} catch (e) {
setError(e.message);
- } finally {
setIsLoading(false);
}
},
diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.js
index bcec4da58..e32049ad7 100644
--- a/apps/web/src/components/note/index.js
+++ b/apps/web/src/components/note/index.js
@@ -5,7 +5,6 @@ import TimeAgo from "timeago-react";
import ListItem from "../list-item";
import { showMoveNoteDialog } from "../../common/dialog-controller";
import { store, useStore } from "../../stores/note-store";
-import { showPasswordDialog } from "../../common/dialog-controller";
import { COLORS } from "../../common";
import { db } from "../../common/db";
import Colors from "../menu/colors";
@@ -15,6 +14,7 @@ import { showUnpinnedToast } from "../../common/toasts";
import { showToast } from "../../utils/toast";
import { hashNavigate } from "../../navigation";
import { showPublishView } from "../publish-view";
+import Vault from "../../common/vault";
function Note(props) {
const { item, index, context } = props;
@@ -235,13 +235,7 @@ const menuItems = [
disableReason: "Please unpublish this note to move it to trash",
onClick: async ({ note }) => {
if (note.locked) {
- const res = await showPasswordDialog("unlock_note", (password) => {
- return db.vault
- .unlock(password)
- .then(() => true)
- .catch(() => false);
- });
- if (!res) return;
+ if (!(await Vault.unlockNote(note.id))) return;
}
await store.delete(note.id).then(() => showItemDeletedToast(note));
},