fix applock interfere with vault unlocking

This commit is contained in:
ammarahm-ed
2022-08-08 11:53:09 +05:00
parent 834cf64390
commit 75e6471998
2 changed files with 17 additions and 15 deletions

View File

@@ -35,6 +35,7 @@ import { SvgView } from '../ui/svg';
import Heading from '../ui/typography/heading';
import Paragraph from '../ui/typography/paragraph';
import { Walkthrough } from '../walkthroughs';
import { useAppState } from '../../utils/hooks/use-app-state';
const Launcher = React.memo(
() => {
@@ -45,6 +46,7 @@ const Launcher = React.memo(
const verifyUser = useUserStore(state => state.verifyUser);
const setVerifyUser = useUserStore(state => state.setVerifyUser);
const deviceMode = useSettingStore(state => state.deviceMode);
const appState = useAppState();
const passwordInputRef = useRef();
const password = useRef();
const introCompleted = useSettingStore(state => state.settings.introCompleted);
@@ -220,12 +222,15 @@ const Launcher = React.memo(
};
useEffect(() => {
if (verifyUser) {
onUnlockBiometrics();
}
init();
}, [verifyUser]);
useEffect(() => {
if (verifyUser && appState === 'active') {
onUnlockBiometrics();
}
}, [appState]);
const onSubmit = async () => {
if (!password.current) return;
try {

View File

@@ -328,19 +328,11 @@ export const useAppEvents = () => {
useSettingStore.getState().setRequestBiometrics(false);
return;
}
if (refValues.current?.prevState === 'background') {
refValues.current.prevState = 'active';
useUserStore.getState().setVerifyUser(true);
let result = await BiometricService.validateUser('Unlock to access your notes');
if (result) {
useUserStore.getState().setVerifyUser(false);
enabled(false);
}
}
}
refValues.current.prevState = 'active';
await reconnectSSE();
refValues.current.prevState = 'active';
await reconnectSSE();
await checkIntentState();
MMKV.removeItem('appState');
let user = await db.user.getUser();
@@ -363,9 +355,14 @@ export const useAppEvents = () => {
if (
SettingsService.get().privacyScreen ||
SettingsService.get().appLockMode === 'background'
) {
!useSettingStore.getState().requestBiometrics ? enabled(true) : null;
}
if (
SettingsService.get().appLockMode === 'background' &&
!useSettingStore.getState().requestBiometrics
) {
useUserStore.getState().setVerifyUser(true);
enabled(true);
}
}
};