[FIX] Screen Lock options i18n (#2120)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
68d7ab06b8
commit
035bdfeca1
|
@ -1,5 +1,3 @@
|
||||||
import I18n from '../i18n';
|
|
||||||
|
|
||||||
export const PASSCODE_KEY = 'kPasscode';
|
export const PASSCODE_KEY = 'kPasscode';
|
||||||
export const LOCKED_OUT_TIMER_KEY = 'kLockedOutTimer';
|
export const LOCKED_OUT_TIMER_KEY = 'kLockedOutTimer';
|
||||||
export const ATTEMPTS_KEY = 'kAttempts';
|
export const ATTEMPTS_KEY = 'kAttempts';
|
||||||
|
@ -12,26 +10,3 @@ export const MAX_ATTEMPTS = 6;
|
||||||
export const TIME_TO_LOCK = 30000;
|
export const TIME_TO_LOCK = 30000;
|
||||||
|
|
||||||
export const DEFAULT_AUTO_LOCK = 1800;
|
export const DEFAULT_AUTO_LOCK = 1800;
|
||||||
|
|
||||||
export const DEFAULT_AUTO_LOCK_OPTIONS = [
|
|
||||||
{
|
|
||||||
title: I18n.t('Local_authentication_auto_lock_60'),
|
|
||||||
value: 60
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: I18n.t('Local_authentication_auto_lock_300'),
|
|
||||||
value: 300
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: I18n.t('Local_authentication_auto_lock_900'),
|
|
||||||
value: 900
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: I18n.t('Local_authentication_auto_lock_1800'),
|
|
||||||
value: 1800
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: I18n.t('Local_authentication_auto_lock_3600'),
|
|
||||||
value: 3600
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import log from '../../utils/log';
|
||||||
import database from '../database';
|
import database from '../database';
|
||||||
import protectedFunction from './helpers/protectedFunction';
|
import protectedFunction from './helpers/protectedFunction';
|
||||||
import fetch from '../../utils/fetch';
|
import fetch from '../../utils/fetch';
|
||||||
import { DEFAULT_AUTO_LOCK, DEFAULT_AUTO_LOCK_OPTIONS } from '../../constants/localAuthentication';
|
import { DEFAULT_AUTO_LOCK } from '../../constants/localAuthentication';
|
||||||
|
|
||||||
const serverInfoKeys = ['Site_Name', 'UI_Use_Real_Name', 'FileUpload_MediaTypeWhiteList', 'FileUpload_MaxFileSize', 'Force_Screen_Lock', 'Force_Screen_Lock_After'];
|
const serverInfoKeys = ['Site_Name', 'UI_Use_Real_Name', 'FileUpload_MediaTypeWhiteList', 'FileUpload_MaxFileSize', 'Force_Screen_Lock', 'Force_Screen_Lock_After'];
|
||||||
|
|
||||||
|
@ -55,19 +55,6 @@ const serverInfoUpdate = async(serverInfo, iconSetting) => {
|
||||||
return { ...allSettings, autoLock };
|
return { ...allSettings, autoLock };
|
||||||
}
|
}
|
||||||
if (setting._id === 'Force_Screen_Lock_After') {
|
if (setting._id === 'Force_Screen_Lock_After') {
|
||||||
// Force_Screen_Lock from server
|
|
||||||
const forceScreenLock = serverInfo.find(item => item._id === 'Force_Screen_Lock')?.valueAsBoolean;
|
|
||||||
|
|
||||||
// if Force_Screen_Lock is disabled on server and Screen Lock is enabled on app
|
|
||||||
if (!forceScreenLock && server.autoLock) {
|
|
||||||
// if the current autoLockTime is one of our default options, we'll keep this value
|
|
||||||
if (DEFAULT_AUTO_LOCK_OPTIONS.find(option => option.value === server.autoLockTime)) {
|
|
||||||
return { ...allSettings, autoLockTime: server.autoLockTime };
|
|
||||||
}
|
|
||||||
// if the current autoLockTime is a value that isn't in our default options, we'll reset
|
|
||||||
return { ...allSettings, autoLockTime: DEFAULT_AUTO_LOCK };
|
|
||||||
}
|
|
||||||
|
|
||||||
// if Force_Screen_Lock_After === 0 and autoLockTime is null, set app's default value
|
// if Force_Screen_Lock_After === 0 and autoLockTime is null, set app's default value
|
||||||
if (setting.valueAsNumber === 0 && !server.autoLockTime) {
|
if (setting.valueAsNumber === 0 && !server.autoLockTime) {
|
||||||
return { ...allSettings, autoLockTime: DEFAULT_AUTO_LOCK };
|
return { ...allSettings, autoLockTime: DEFAULT_AUTO_LOCK };
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { CustomIcon } from '../lib/Icons';
|
||||||
import database from '../lib/database';
|
import database from '../lib/database';
|
||||||
import { supportedBiometryLabel, changePasscode, checkHasPasscode } from '../utils/localAuthentication';
|
import { supportedBiometryLabel, changePasscode, checkHasPasscode } from '../utils/localAuthentication';
|
||||||
import { DisclosureImage } from '../containers/DisclosureIndicator';
|
import { DisclosureImage } from '../containers/DisclosureIndicator';
|
||||||
import { DEFAULT_AUTO_LOCK_OPTIONS, DEFAULT_AUTO_LOCK } from '../constants/localAuthentication';
|
import { DEFAULT_AUTO_LOCK } from '../constants/localAuthentication';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
listPadding: {
|
listPadding: {
|
||||||
|
@ -54,6 +54,29 @@ class ScreenLockConfigView extends React.Component {
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defaultAutoLockOptions = [
|
||||||
|
{
|
||||||
|
title: I18n.t('Local_authentication_auto_lock_60'),
|
||||||
|
value: 60
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: I18n.t('Local_authentication_auto_lock_300'),
|
||||||
|
value: 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: I18n.t('Local_authentication_auto_lock_900'),
|
||||||
|
value: 900
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: I18n.t('Local_authentication_auto_lock_1800'),
|
||||||
|
value: 1800
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: I18n.t('Local_authentication_auto_lock_3600'),
|
||||||
|
value: 3600
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
init = async() => {
|
init = async() => {
|
||||||
const { server } = this.props;
|
const { server } = this.props;
|
||||||
const serversDB = database.servers;
|
const serversDB = database.servers;
|
||||||
|
@ -168,18 +191,24 @@ class ScreenLockConfigView extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderAutoLockItems = () => {
|
renderAutoLockItems = () => {
|
||||||
const { autoLock } = this.state;
|
const { autoLock, autoLockTime } = this.state;
|
||||||
const { theme, Force_Screen_Lock_After, Force_Screen_Lock } = this.props;
|
const { theme, Force_Screen_Lock_After, Force_Screen_Lock } = this.props;
|
||||||
if (!autoLock) {
|
if (!autoLock) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
let items = DEFAULT_AUTO_LOCK_OPTIONS;
|
let items = this.defaultAutoLockOptions;
|
||||||
if (Force_Screen_Lock && Force_Screen_Lock_After > 0) {
|
if (Force_Screen_Lock && Force_Screen_Lock_After > 0) {
|
||||||
items = [{
|
items = [{
|
||||||
title: I18n.t('After_seconds_set_by_admin', { seconds: Force_Screen_Lock_After }),
|
title: I18n.t('After_seconds_set_by_admin', { seconds: Force_Screen_Lock_After }),
|
||||||
value: Force_Screen_Lock_After,
|
value: Force_Screen_Lock_After,
|
||||||
disabled: true
|
disabled: true
|
||||||
}];
|
}];
|
||||||
|
// if Force_Screen_Lock is disabled and autoLockTime is a value that isn't on our defaultOptions we'll show it
|
||||||
|
} else if (Force_Screen_Lock_After === autoLockTime && !items.find(item => item.value === autoLockTime)) {
|
||||||
|
items.push({
|
||||||
|
title: I18n.t('After_seconds_set_by_admin', { seconds: Force_Screen_Lock_After }),
|
||||||
|
value: Force_Screen_Lock_After
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
Loading…
Reference in New Issue