Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Screen Lock Time respect local value #2141

Merged
merged 2 commits into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/lib/methods/getSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ const serverInfoUpdate = async(serverInfo, iconSetting) => {
return { ...allSettings, autoLock };
}
if (setting._id === 'Force_Screen_Lock_After') {
const forceScreenLock = serverInfo.find(s => s._id === 'Force_Screen_Lock')?.valueAsBoolean;

// if Force_Screen_Lock_After === 0 and autoLockTime is null, set app's default value
if (setting.valueAsNumber === 0 && !server.autoLockTime) {
return { ...allSettings, autoLockTime: DEFAULT_AUTO_LOCK };
}
// if Force_Screen_Lock_After > 0, use it
if (setting.valueAsNumber > 0) {
// if Force_Screen_Lock_After > 0 and forceScreenLock is enabled, use it
if (setting.valueAsNumber > 0 && forceScreenLock) {
return { ...allSettings, autoLockTime: setting.valueAsNumber };
}
}
Expand Down
19 changes: 19 additions & 0 deletions app/views/ScreenLockConfigView.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ class ScreenLockConfigView extends React.Component {
this.init();
}

componentWillUnmount() {
if (this.observable && this.observable.unsubscribe) {
this.observable.unsubscribe();
}
}

defaultAutoLockOptions = [
{
title: I18n.t('Local_authentication_auto_lock_60'),
Expand Down Expand Up @@ -94,6 +100,19 @@ class ScreenLockConfigView extends React.Component {

const biometryLabel = await supportedBiometryLabel();
this.setState({ biometryLabel });

this.observe();
}

/*
* We should observe biometry value
* because it can be changed by PasscodeChange
* when the user set his first passcode
*/
observe = () => {
this.observable = this.serverRecord?.observe()?.subscribe(({ biometry }) => {
this.setState({ biometry });
});
}

save = async() => {
Expand Down