Skip to content

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

fix: auto lock note on vault lock

thecodrr9fbbc1015b06
diff --git a/apps/web/src/components/unlock/index.js b/apps/web/src/components/unlock/index.js
index 4fbc2e570..501690b76 100644
--- a/apps/web/src/components/unlock/index.js
+++ b/apps/web/src/components/unlock/index.js
@@ -33,10 +33,10 @@ function Unlock(props) {
const note = await db.vault.open(noteId, password);
openLockedSession(note);
} catch (e) {
- if (e === "ciphertext cannot be decrypted using that key") {
+ if (e.message.includes("ciphertext cannot be decrypted using that key")) {
setIsWrong(true);
} else {
- showToast("error", "Cannnot unlock note: " + e);
+ showToast("error", "Cannot unlock note: " + e);
console.error(e);
}
} finally {
diff --git a/apps/web/src/stores/editor-store.js b/apps/web/src/stores/editor-store.js
index 175a5aee3..e2b93aff9 100644
--- a/apps/web/src/stores/editor-store.js
+++ b/apps/web/src/stores/editor-store.js
@@ -48,6 +48,11 @@ class EditorStore extends BaseStore {
EV.subscribe(EVENTS.userLoggedOut, () => {
hashNavigate("/notes/create", { replace: true, addNonce: true });
});
+
+ EV.subscribe(EVENTS.vaultLocked, () => {
+ const { id, locked } = this.get().session;
+ if (locked) hashNavigate(`/notes/${id}/unlock`, { replace: true });
+ });
};
refresh = async () => {