1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Mobile: Fixes #8285: Fix sharing data with the app

This commit is contained in:
Laurent Cozic 2023-06-08 16:23:48 +01:00
parent 3338164f43
commit 37b745c69e

View File

@ -113,7 +113,7 @@ import { Theme, ThemeAppearance } from '@joplin/lib/themes/type';
import { AppState } from './utils/types';
import ProfileSwitcher from './components/ProfileSwitcher/ProfileSwitcher';
import ProfileEditor from './components/ProfileSwitcher/ProfileEditor';
import sensorInfo from './components/biometrics/sensorInfo';
import sensorInfo, { SensorInfo } from './components/biometrics/sensorInfo';
import { getCurrentProfile } from '@joplin/lib/services/profileConfig';
import { getDatabaseName, getProfilesRootDir, getResourceDir, setDispatch } from './services/profiles';
@ -130,6 +130,10 @@ const logReducerAction = function(action: any) {
// reg.logger().debug('Reducer action', msg.join(', '));
};
const biometricsEnabled = (sensorInfo: SensorInfo): boolean => {
return !!sensorInfo && sensorInfo.enabled;
};
const generalMiddleware = (store: any) => (next: any) => async (action: any) => {
logReducerAction(action);
PoorManIntervals.update(); // This function needs to be called regularly so put it here
@ -803,7 +807,21 @@ class AppComponent extends React.Component {
await initialize(this.props.dispatch);
this.setState({ sensorInfo: await sensorInfo() });
const loadedSensorInfo = await sensorInfo();
this.setState({ sensorInfo: loadedSensorInfo });
// If biometrics is disabled we set biometricsDone to `true`. We do
// it with a delay so that the component is properly mounted, and
// the componentDidUpdate gets triggered (which in turns will handle
// the share data, if any).
setTimeout(() => {
if (!biometricsEnabled(loadedSensorInfo)) {
this.props.dispatch({
type: 'BIOMETRICS_DONE_SET',
value: true,
});
}
}, 100);
this.props.dispatch({
type: 'APP_STATE_SET',
@ -973,11 +991,10 @@ class AppComponent extends React.Component {
// const statusBarStyle = theme.appearance === 'light-content';
const statusBarStyle = 'light-content';
const biometricIsEnabled = !!this.state.sensorInfo && this.state.sensorInfo.enabled;
const shouldShowMainContent = !biometricIsEnabled || this.props.biometricsDone;
const shouldShowMainContent = !biometricsEnabled(this.state.sensorInfo) || this.props.biometricsDone;
logger.info('root.biometrics: biometricsDone', this.props.biometricsDone);
logger.info('root.biometrics: biometricIsEnabled', biometricIsEnabled);
logger.info('root.biometrics: biometricsEnabled', biometricsEnabled(this.state.sensorInfo));
logger.info('root.biometrics: shouldShowMainContent', shouldShowMainContent);
logger.info('root.biometrics: this.state.sensorInfo', this.state.sensorInfo);