1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-03-26 21:12:59 +02:00

Mobile: Fixed regression in biometric check

Due to f0ade0243578da6e1f6a7c7467d6f4cc16136196
This commit is contained in:
Laurent Cozic 2023-05-29 13:14:09 +01:00
parent 192bfb5555
commit b19f1a1023
3 changed files with 14 additions and 8 deletions
packages
app-mobile
components/screens
root.tsx
lib/components/shared

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

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

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