Skip to content

Commit

Permalink
[Issue-1491] Timeout when re-open the app
Browse files Browse the repository at this point in the history
  • Loading branch information
dominhquang committed Oct 1, 2024
1 parent f356795 commit f152f94
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"react-i18next": "^12.1.4",
"react-native": "^0.72.4",
"react-native-animatable": "^1.3.3",
"react-native-background-timer": "2.1.1",
"react-native-camera": "^4.2.1",
"react-native-code-push": "^8.1.1",
"react-native-config": "^1.5.1",
Expand Down Expand Up @@ -164,6 +165,7 @@
"@types/react-redux": "^7.1.24",
"@types/react-test-renderer": "^18.0.0",
"@types/redux-persist": "^4.3.1",
"@types/react-native-background-timer": "^2.0.0",
"@types/url-parse": "^1.4.8",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
Expand Down
9 changes: 9 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { useGetBrowserConfig } from 'hooks/static-content/useGetBrowserConfig';
import RNRestart from 'react-native-restart';
import { ImageLogosMap } from 'assets/logo';
import { GlobalInstructionModalContextProvider } from 'providers/GlobalInstructionModalContext';
import BackgroundTimer from 'react-native-background-timer';

const layerScreenStyle: StyleProp<any> = {
top: 0,
Expand Down Expand Up @@ -120,10 +121,17 @@ AppState.addEventListener('change', (state: string) => {

if (state === 'background') {
mmkvStore.set('lastTimeLogin', Date.now());
console.log('timeAutoLock', timeAutoLock);
if (timeAutoLock === LockTimeout.ALWAYS) {
// Lock master password incase always require
setIsShowRemindBackupModal(false);
keyringLock().catch((e: Error) => console.log(e));
} else {
BackgroundTimer.start();
setTimeout(() => {
setIsShowRemindBackupModal(false);
lock();
}, timeAutoLock * 60 * 1000);
}
if (isUseBiometric) {
lockWhenActive = true;
Expand All @@ -135,6 +143,7 @@ AppState.addEventListener('change', (state: string) => {
}
}
} else if (state === 'active') {
BackgroundTimer.stop();
if (lockWhenActive) {
if (isMasterPasswordLocked) {
setIsShowRemindBackupModal(false);
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6037,6 +6037,11 @@
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb"
integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==

"@types/react-native-background-timer@^2.0.0":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@types/react-native-background-timer/-/react-native-background-timer-2.0.2.tgz#22f9126124068a0ee6a812e16f98e270c2b9b2c7"
integrity sha512-cMAep0M5yqUHjiiRPvGiviqiJYdI45KSjbI5ufsIFSQGFwHwrHJC/8yawNhy0G3Gix6fufWLsEj6jC5niUNHiQ==

"@types/react-native-bcrypt@^2.4.2":
version "2.4.6"
resolved "https://registry.yarnpkg.com/@types/react-native-bcrypt/-/react-native-bcrypt-2.4.6.tgz#92f2357f884808c354e60e3b70e980cc64a22b71"
Expand Down Expand Up @@ -16823,6 +16828,11 @@ react-native-animatable@^1.3.3:
dependencies:
prop-types "^15.8.1"

[email protected]:
version "2.1.1"
resolved "https://registry.yarnpkg.com/react-native-background-timer/-/react-native-background-timer-2.1.1.tgz#9a2489681ab2f8033c213c73272e9d4c47572cd5"
integrity sha512-cuXIIv+dcG8a8qkTD8pMzeqOEZCO+UGKglZWIe1osve+yJslmCowYQff+bI9xa7NOt2w+Vtd4L3d9JonlSqODg==

react-native-camera@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/react-native-camera/-/react-native-camera-4.2.1.tgz#caf74081f055e89d7e9b0cd5108965d808c60e90"
Expand Down

0 comments on commit f152f94

Please sign in to comment.