diff --git a/package.json b/package.json index 7239e1dd4..7e7ed7b12 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/src/App.tsx b/src/App.tsx index 25892ac61..14b8d6957 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -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 = { top: 0, @@ -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; @@ -135,6 +143,7 @@ AppState.addEventListener('change', (state: string) => { } } } else if (state === 'active') { + BackgroundTimer.stop(); if (lockWhenActive) { if (isMasterPasswordLocked) { setIsShowRemindBackupModal(false); diff --git a/test.ts b/test.ts deleted file mode 100644 index 107a4f413..000000000 --- a/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - id: 3, - priority: 1, - position: 'token', - repeat: 'once', - content: 'SHOW POPUP TO CHECK INSTRUCTION', - media: null, - position_params: [], - info: { - id: 5, - name: 'Popup with instruction', - description: 'Test', - start_time: '2024-03-19T17:00:00.000Z', - stop_time: '2024-04-05T17:00:00.000Z', - platforms: ['mobile'], - }, - buttons: [ - { - id: 5, - label: 'Continue', - color: 'primary', - instruction: { - id: 1, - confirm_label: 'Continue', - cancel_label: 'Cancel', - instruction_id: 7, - group: 'earning', - slug: 'DAPP_STAKING', - }, - action: { id: 6, url: 'subwallet://home/main/earning', screen: null, params: null, is_cancel: null }, - }, - ], - conditions: {}, - }, -]; diff --git a/yarn.lock b/yarn.lock index 66bb1b5d7..2e3f36281 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6046,6 +6046,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" @@ -16802,6 +16807,11 @@ react-native-animatable@^1.3.3: dependencies: prop-types "^15.8.1" +react-native-background-timer@2.1.1: + 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"