Mobile: Fixed regression in biometric check

Due to f0ade02435
pull/8253/head
Laurent Cozic 2023-05-29 13:14:09 +01:00
parent 192bfb5555
commit b19f1a1023
3 changed files with 14 additions and 8 deletions

View File

@ -98,6 +98,8 @@ class ConfigScreenComponent extends BaseScreenComponent {
} }
}; };
this.saveButton_press = this.saveButton_press.bind(this);
this.syncStatusButtonPress_ = () => { this.syncStatusButtonPress_ = () => {
void NavService.go('Status'); void NavService.go('Status');
}; };
@ -199,6 +201,8 @@ class ConfigScreenComponent extends BaseScreenComponent {
this.logButtonPress_ = () => { this.logButtonPress_ = () => {
void NavService.go('Log'); void NavService.go('Log');
}; };
this.handleSetting = this.handleSetting.bind(this);
} }
public async checkFilesystemPermission() { public async checkFilesystemPermission() {
@ -482,8 +486,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
if (key === 'security.biometricsEnabled' && !!value) { if (key === 'security.biometricsEnabled' && !!value) {
try { try {
await biometricAuthenticate(); await biometricAuthenticate();
shared.updateSettingValue(this, key, value); shared.updateSettingValue(this, key, value, async () => await this.saveButton_press());
await this.saveButton_press();
} catch (error) { } catch (error) {
shared.updateSettingValue(this, key, false); shared.updateSettingValue(this, key, false);
Alert.alert(error.message); Alert.alert(error.message);
@ -492,8 +495,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
} }
if (key === 'security.biometricsEnabled' && !value) { if (key === 'security.biometricsEnabled' && !value) {
shared.updateSettingValue(this, key, value); shared.updateSettingValue(this, key, value, async () => await this.saveButton_press());
await this.saveButton_press();
return true; return true;
} }

View File

@ -866,7 +866,7 @@ class AppComponent extends React.Component {
} }
} }
public componentDidUpdate(prevProps: any) { public async componentDidUpdate(prevProps: any) {
if (this.props.biometricsDone !== prevProps.biometricsDone && this.props.biometricsDone) { if (this.props.biometricsDone !== prevProps.biometricsDone && this.props.biometricsDone) {
logger.info('Sharing: componentDidUpdate: biometricsDone'); logger.info('Sharing: componentDidUpdate: biometricsDone');
void this.handleShareData(); void this.handleShareData();
@ -979,6 +979,7 @@ class AppComponent extends React.Component {
const biometricIsEnabled = !!this.state.sensorInfo && this.state.sensorInfo.enabled; const biometricIsEnabled = !!this.state.sensorInfo && this.state.sensorInfo.enabled;
const shouldShowMainContent = !biometricIsEnabled || this.props.biometricsDone; const shouldShowMainContent = !biometricIsEnabled || this.props.biometricsDone;
logger.info('root.biometrics: biometricsDone', this.props.biometricsDone);
logger.info('root.biometrics: biometricIsEnabled', biometricIsEnabled); logger.info('root.biometrics: biometricIsEnabled', biometricIsEnabled);
logger.info('root.biometrics: shouldShowMainContent', shouldShowMainContent); logger.info('root.biometrics: shouldShowMainContent', shouldShowMainContent);
logger.info('root.biometrics: this.state.sensorInfo', this.state.sensorInfo); logger.info('root.biometrics: this.state.sensorInfo', this.state.sensorInfo);
@ -1008,7 +1009,7 @@ class AppComponent extends React.Component {
{ shouldShowMainContent && <AppNav screens={appNavInit} dispatch={this.props.dispatch} /> } { shouldShowMainContent && <AppNav screens={appNavInit} dispatch={this.props.dispatch} /> }
</View> </View>
<DropdownAlert ref={(ref: any) => this.dropdownAlert_ = ref} tapToCloseEnabled={true} /> <DropdownAlert ref={(ref: any) => this.dropdownAlert_ = ref} tapToCloseEnabled={true} />
{ this.state.sensorInfo && <BiometricPopup { !shouldShowMainContent && <BiometricPopup
dispatch={this.props.dispatch} dispatch={this.props.dispatch}
themeId={this.props.themeId} themeId={this.props.themeId}
sensorInfo={this.state.sensorInfo} sensorInfo={this.state.sensorInfo}
@ -1054,6 +1055,7 @@ const mapStateToProps = (state: any) => {
themeId: state.settings.theme, themeId: state.settings.theme,
noteSideMenuOptions: state.noteSideMenuOptions, noteSideMenuOptions: state.noteSideMenuOptions,
biometricsDone: state.biometricsDone, biometricsDone: state.biometricsDone,
biometricsEnabled: state.settings['security.biometricsEnabled'],
}; };
}; };

View File

@ -75,7 +75,9 @@ shared.checkSyncConfigMessages = function(comp) {
return output; return output;
}; };
shared.updateSettingValue = function(comp, key, value) { shared.updateSettingValue = function(comp, key, value, callback = null) {
if (!callback) callback = () => {};
comp.setState(state => { comp.setState(state => {
// @react-native-community/slider (4.4.0) will emit a valueChanged event // @react-native-community/slider (4.4.0) will emit a valueChanged event
// when the component is mounted, even though the value hasn't changed. // when the component is mounted, even though the value hasn't changed.
@ -99,7 +101,7 @@ shared.updateSettingValue = function(comp, key, value) {
settings: settings, settings: settings,
changedSettingKeys: changedSettingKeys, changedSettingKeys: changedSettingKeys,
}; };
}); }, callback);
}; };
shared.scheduleSaveSettings = function(comp) { shared.scheduleSaveSettings = function(comp) {