Skip to content

Commit

Permalink
mobile: fix vault unlocking
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed Mar 27, 2024
1 parent 3037a15 commit 210bdea
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions apps/mobile/app/screens/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,10 @@ const useLockedNoteHandler = () => {

try {
const note = await db.vault.open(tabRef.current?.noteId, password);
if (enrollBiometrics) {
if (enrollBiometrics && note) {
try {
await db.vault.unlock(password);
const unlocked = await db.vault.unlock(password);
if (!unlocked) throw new Error("Incorrect vault password");
await BiometicService.storeCredentials(password);
eSendEvent("vaultUpdated");
ToastManager.show({
Expand All @@ -282,8 +283,7 @@ const useLockedNoteHandler = () => {
heading: "Incorrect password",
message:
"Please enter the correct vault password to enable biometrics.",
type: "error",
context: "local"
type: "error"
});
}
}
Expand All @@ -297,8 +297,7 @@ const useLockedNoteHandler = () => {
console.log(e);
ToastManager.show({
heading: "Incorrect password",
type: "error",
context: "local"
type: "error"
});
}
};
Expand All @@ -310,7 +309,9 @@ const useLockedNoteHandler = () => {
useTabStore.getState().biometryEnrolled &&
!editorState().movedAway)
) {
unlockWithBiometrics();
setTimeout(() => {
unlockWithBiometrics();
}, 150);
} else {
console.log("Biometrics unavailable.", editorState().movedAway);
if (!editorState().movedAway) {
Expand All @@ -336,7 +337,7 @@ const useLockedNoteHandler = () => {
return () => {
subs.map((s) => s?.unsubscribe());
};
}, [tab?.id]);
}, [tab?.id, tab?.locked]);

return null;
};

0 comments on commit 210bdea

Please sign in to comment.