Apply on saved data

This commit is contained in:
Diego Mello 2020-04-16 10:52:56 -03:00
parent 67a934313e
commit fa93c26744
2 changed files with 16 additions and 25 deletions

View File

@ -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);
};

View File

@ -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 }) => (