mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 19:57:52 +01:00
Merge pull request #8949 from streetwriters/mobile-fix-ipad-biometric-unlock
mobile: Fix biometric unlock not working on iPad and tablet devices
This commit is contained in:
@@ -62,6 +62,7 @@ import { fluidTabsRef } from "../../utils/global-refs";
|
|||||||
import { strings } from "@notesnook/intl";
|
import { strings } from "@notesnook/intl";
|
||||||
import { i18n } from "@lingui/core";
|
import { i18n } from "@lingui/core";
|
||||||
import { useVaultStatus } from "../../hooks/use-vault-status";
|
import { useVaultStatus } from "../../hooks/use-vault-status";
|
||||||
|
import { useSettingStore } from "../../stores/use-setting-store";
|
||||||
|
|
||||||
const style: ViewStyle = {
|
const style: ViewStyle = {
|
||||||
height: "100%",
|
height: "100%",
|
||||||
@@ -231,7 +232,6 @@ const useLockedNoteHandler = () => {
|
|||||||
const unlockWithBiometrics = async () => {
|
const unlockWithBiometrics = async () => {
|
||||||
try {
|
try {
|
||||||
if (!tabRef.current?.session?.noteLocked || !tabRef.current) return;
|
if (!tabRef.current?.session?.noteLocked || !tabRef.current) return;
|
||||||
console.log("Trying to unlock with biometrics...");
|
|
||||||
const credentials = await BiometricService.getCredentials(
|
const credentials = await BiometricService.getCredentials(
|
||||||
"Unlock note",
|
"Unlock note",
|
||||||
"Unlock note to open it in editor."
|
"Unlock note to open it in editor."
|
||||||
@@ -320,12 +320,16 @@ const useLockedNoteHandler = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const unlock = () => {
|
const unlock = (forced?: boolean) => {
|
||||||
|
const isMovedAway =
|
||||||
|
useSettingStore.getState().deviceMode !== "mobile"
|
||||||
|
? false
|
||||||
|
: editorState().movedAway;
|
||||||
if (
|
if (
|
||||||
(tabRef.current?.session?.locked,
|
tabRef.current?.session?.locked &&
|
||||||
useTabStore.getState().biometryAvailable &&
|
useTabStore.getState().biometryAvailable &&
|
||||||
useTabStore.getState().biometryEnrolled &&
|
useTabStore.getState().biometryEnrolled &&
|
||||||
!editorState().movedAway)
|
(!isMovedAway || forced)
|
||||||
) {
|
) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
unlockWithBiometrics();
|
unlockWithBiometrics();
|
||||||
@@ -344,13 +348,15 @@ const useLockedNoteHandler = () => {
|
|||||||
const subs = [
|
const subs = [
|
||||||
eSubscribeEvent(eUnlockNote, unlock),
|
eSubscribeEvent(eUnlockNote, unlock),
|
||||||
eSubscribeEvent(eUnlockWithBiometrics, () => {
|
eSubscribeEvent(eUnlockWithBiometrics, () => {
|
||||||
unlock();
|
unlock(true);
|
||||||
}),
|
}),
|
||||||
eSubscribeEvent(eUnlockWithPassword, onSubmit)
|
eSubscribeEvent(eUnlockWithPassword, onSubmit)
|
||||||
];
|
];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
tabRef.current?.session?.locked &&
|
tabRef.current?.session?.locked &&
|
||||||
fluidTabsRef.current?.page() === "editor"
|
(fluidTabsRef.current?.page() === "editor" ||
|
||||||
|
useSettingStore.getState().deviceMode !== "mobile")
|
||||||
) {
|
) {
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user