diff --git a/app/utils/localAuthentication.js b/app/utils/localAuthentication.js index 82c3f42e6..6c452cc6c 100644 --- a/app/utils/localAuthentication.js +++ b/app/utils/localAuthentication.js @@ -32,18 +32,18 @@ export const localAuthenticate = async(server) => { return Promise.reject(); } - const diffToLastSession = moment().diff(serverRecord?.lastLocalAuthenticatedSession, 'seconds'); - console.log('localAuthenticate -> diffToLastSession', diffToLastSession); - // if (diffToLastSession >= 5) { - // const supported = await LocalAuthentication.supportedAuthenticationTypesAsync() - // console.log('localAuthenticate -> supported', supported); - // const authResult = await LocalAuthentication.authenticateAsync(); - // if (authResult?.success) { - // await saveLastLocalAuthenticationSession(server); - // } - // return Promise.resolve(authResult?.success); - // } else { - // await saveLastLocalAuthenticationSession(server); - // } + if (serverRecord?.autoLock) { + const diffToLastSession = moment().diff(serverRecord?.lastLocalAuthenticatedSession, 'seconds'); + if (diffToLastSession >= serverRecord?.autoLockTime) { + const supported = await LocalAuthentication.supportedAuthenticationTypesAsync(); + const authResult = await LocalAuthentication.authenticateAsync(); + if (authResult?.success) { + await saveLastLocalAuthenticationSession(server); + } + return Promise.resolve(authResult?.success); + } else { + await saveLastLocalAuthenticationSession(server); + } + } return Promise.resolve(true); }; diff --git a/app/views/ScreenLockConfigView.js b/app/views/ScreenLockConfigView.js index 019af19c2..6c88f9a95 100644 --- a/app/views/ScreenLockConfigView.js +++ b/app/views/ScreenLockConfigView.js @@ -1,9 +1,10 @@ import React from 'react'; import PropTypes from 'prop-types'; import { - StyleSheet, FlatList, View, Text, Linking, Switch, ScrollView + StyleSheet, View, Switch, ScrollView } from 'react-native'; import { SafeAreaView } from 'react-navigation'; +import { connect } from 'react-redux'; import I18n from '../i18n'; import { themedHeader } from '../utils/navigation'; @@ -15,7 +16,6 @@ import Separator from '../containers/Separator'; import ListItem from '../containers/ListItem'; import { CustomIcon } from '../lib/Icons'; import database from '../lib/database'; -import { connect } from 'react-redux'; const DEFAULT_AUTO_LOCK = [ { @@ -44,19 +44,10 @@ const styles = StyleSheet.create({ listPadding: { paddingVertical: 36 }, - info: { - paddingTop: 25, - paddingBottom: 18, - paddingHorizontal: 16 - }, - infoText: { - fontSize: 16, - ...sharedStyles.textRegular - }, sectionSeparatorBorder: { ...sharedStyles.separatorVertical, height: 36 - }, + } }); const SectionSeparator = React.memo(({ theme }) => (