Skip to content

Commit

Permalink
Merge pull request #2554 from myxmaster/improve-refreshing-of-securit…
Browse files Browse the repository at this point in the history
…y-settings

Refresh security settings on screen focus
  • Loading branch information
kaloudis authored Nov 23, 2024
2 parents f28aae3 + 09136c9 commit afd044f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
14 changes: 14 additions & 0 deletions stores/SettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import isEqual from 'lodash/isEqual';
import BackendUtils from '../utils/BackendUtils';
import { localeString } from '../utils/LocaleUtils';
import { doTorRequest, RequestMethod } from '../utils/TorUtils';
import { getSupportedBiometryType } from '../utils/BiometricUtils';

// lndhub
import LoginRequest from './../models/LoginRequest';
Expand Down Expand Up @@ -1821,6 +1822,19 @@ export default class SettingsStore {
this.settings.pin ||
this.isBiometryConfigured());

public checkBiometricsStatus = async () => {
const biometryType = await getSupportedBiometryType();
if (this.settings.supportedBiometryType !== biometryType) {
this.updateSettings({
supportedBiometryType: biometryType
});
}
return {
supportedBiometryType: biometryType,
isBiometryEnabled: this.settings.isBiometryEnabled
};
};

public isBiometryConfigured = () =>
this.settings != null &&
this.settings.isBiometryEnabled &&
Expand Down
22 changes: 16 additions & 6 deletions views/Settings/Security.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,26 @@ export default class Security extends React.Component<
isBiometryEnabled: undefined
};

async componentDidMount() {
componentDidMount() {
this.checkSettings();
this.props.navigation.addListener('focus', this.checkSettings);
}

componentWillUnmount() {
this.props.navigation.removeListener &&
this.props.navigation.removeListener('focus', this.checkSettings);
}

checkSettings = async () => {
const { SettingsStore } = this.props;
const { getSettings } = SettingsStore;
const settings = await getSettings();
const biometricsStatus = await SettingsStore.checkBiometricsStatus();
const settings = await SettingsStore.getSettings();

this.setState({
scramblePin: settings.scramblePin ?? true,
loginBackground: settings.loginBackground ?? false,
isBiometryEnabled: settings.isBiometryEnabled,
supportedBiometryType: settings.supportedBiometryType
isBiometryEnabled: biometricsStatus.isBiometryEnabled,
supportedBiometryType: biometricsStatus.supportedBiometryType
});

if (settings.pin) {
Expand Down Expand Up @@ -135,7 +145,7 @@ export default class Security extends React.Component<
displaySecurityItems: minPinItems
});
}
}
};

async handleBiometricsSwitchChange(value: boolean): Promise<void> {
const isVerified = await verifyBiometry(
Expand Down

0 comments on commit afd044f

Please sign in to comment.