[FIX] Touch/Face ID toggle does not enable automatically the first time (#4576)

* [FIX] Touch/Face ID toggle does not enable automatically the first time

* minor tweak no competition setState
This commit is contained in:
Reinaldo Neto 2022-10-07 12:34:51 -03:00 committed by GitHub
parent 63e2a3a85c
commit 300e5fc793
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 6 deletions

View File

@ -91,14 +91,15 @@ class ScreenLockConfigView extends React.Component<IScreenLockConfigViewProps, I
const { server } = this.props; const { server } = this.props;
const serversDB = database.servers; const serversDB = database.servers;
const serversCollection = serversDB.get('servers'); const serversCollection = serversDB.get('servers');
const hasBiometry = userPreferences.getBool(BIOMETRY_ENABLED_KEY) ?? DEFAULT_BIOMETRY;
try { try {
this.serverRecord = await serversCollection.find(server); this.serverRecord = await serversCollection.find(server);
this.setState({ this.setState(
autoLock: this.serverRecord?.autoLock, {
autoLockTime: this.serverRecord?.autoLockTime === null ? DEFAULT_AUTO_LOCK : this.serverRecord?.autoLockTime, autoLock: this.serverRecord?.autoLock,
biometry: hasBiometry autoLockTime: this.serverRecord?.autoLockTime === null ? DEFAULT_AUTO_LOCK : this.serverRecord?.autoLockTime
}); },
() => this.hasBiometry()
);
} catch (error) { } catch (error) {
// Do nothing // Do nothing
} }
@ -119,6 +120,11 @@ class ScreenLockConfigView extends React.Component<IScreenLockConfigViewProps, I
}); });
}; };
hasBiometry = () => {
const biometry = userPreferences.getBool(BIOMETRY_ENABLED_KEY) ?? DEFAULT_BIOMETRY;
this.setState({ biometry });
};
changePasscode = async ({ force }: { force: boolean }) => { changePasscode = async ({ force }: { force: boolean }) => {
logEvent(events.SLC_CHANGE_PASSCODE); logEvent(events.SLC_CHANGE_PASSCODE);
await changePasscode({ force }); await changePasscode({ force });
@ -133,6 +139,7 @@ class ScreenLockConfigView extends React.Component<IScreenLockConfigViewProps, I
if (autoLock) { if (autoLock) {
try { try {
await checkHasPasscode({ force: false }); await checkHasPasscode({ force: false });
this.hasBiometry();
} catch { } catch {
this.toggleAutoLock(); this.toggleAutoLock();
} }