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

Android: Fixes #7691: Sharing file to Joplin does not work

This commit is contained in:
Laurent Cozic 2023-02-10 16:12:14 +00:00
parent 02e8307093
commit a1a10a6c55
3 changed files with 34 additions and 6 deletions

View File

@ -9,6 +9,7 @@ import { _ } from '@joplin/lib/locale';
interface Props { interface Props {
themeId: number; themeId: number;
sensorInfo: SensorInfo; sensorInfo: SensorInfo;
dispatch: Function;
} }
export default (props: Props) => { export default (props: Props) => {
@ -49,6 +50,11 @@ export default (props: Props) => {
} else { } else {
setTryBiometricsCheck(true); setTryBiometricsCheck(true);
} }
props.dispatch({
type: 'BIOMETRICS_DONE_SET',
value: true,
});
}; };
Alert.alert( Alert.alert(
@ -67,7 +73,7 @@ export default (props: Props) => {
}, },
] ]
); );
}, [initialPromptDone, props.sensorInfo.supportedSensors, display]); }, [initialPromptDone, props.sensorInfo.supportedSensors, display, props.dispatch]);
const windowSize = useMemo(() => { const windowSize = useMemo(() => {
return { return {
@ -76,6 +82,15 @@ export default (props: Props) => {
}; };
}, []); }, []);
useEffect(() => {
if (!display) {
props.dispatch({
type: 'BIOMETRICS_DONE_SET',
value: true,
});
}
}, [display, props.dispatch]);
const renderTryAgainButton = () => { const renderTryAgainButton = () => {
if (!display || tryBiometricsCheck || !initialPromptDone) return null; if (!display || tryBiometricsCheck || !initialPromptDone) return null;
return <Button title={_('Try again')} onPress={() => setTryBiometricsCheck(true)} />; return <Button title={_('Try again')} onPress={() => setTryBiometricsCheck(true)} />;

View File

@ -727,7 +727,10 @@ class AppComponent extends React.Component {
}; };
this.handleOpenURL_ = (event: any) => { this.handleOpenURL_ = (event: any) => {
if (event.url === ShareExtension.shareURL) { // If this is called while biometrics haven't been done yet, we can
// ignore the call, because handleShareData() will be called once
// biometricsDone is `true`.
if (event.url === ShareExtension.shareURL && this.props.biometricsDone) {
void this.handleShareData(); void this.handleShareData();
} }
}; };
@ -812,8 +815,6 @@ class AppComponent extends React.Component {
this.appStateChangeListener_ = RNAppState.addEventListener('change', this.onAppStateChange_); this.appStateChangeListener_ = RNAppState.addEventListener('change', this.onAppStateChange_);
this.unsubscribeScreenWidthChangeHandler_ = Dimensions.addEventListener('change', this.handleScreenWidthChange_); this.unsubscribeScreenWidthChangeHandler_ = Dimensions.addEventListener('change', this.handleScreenWidthChange_);
await this.handleShareData();
setupQuickActions(this.props.dispatch, this.props.selectedFolderId); setupQuickActions(this.props.dispatch, this.props.selectedFolderId);
await setupNotifications(this.props.dispatch); await setupNotifications(this.props.dispatch);
@ -848,6 +849,10 @@ class AppComponent extends React.Component {
duration: 600, duration: 600,
}).start(); }).start();
} }
if (this.props.biometricsDone !== prevProps.biometricsDone && this.props.biometricsDone) {
void this.handleShareData();
}
} }
private async backButtonHandler() { private async backButtonHandler() {
@ -973,10 +978,11 @@ class AppComponent extends React.Component {
</View> </View>
<DropdownAlert ref={(ref: any) => this.dropdownAlert_ = ref} tapToCloseEnabled={true} /> <DropdownAlert ref={(ref: any) => this.dropdownAlert_ = ref} tapToCloseEnabled={true} />
<Animated.View pointerEvents='none' style={{ position: 'absolute', backgroundColor: 'black', opacity: this.state.sideMenuContentOpacity, width: '100%', height: '120%' }}/> <Animated.View pointerEvents='none' style={{ position: 'absolute', backgroundColor: 'black', opacity: this.state.sideMenuContentOpacity, width: '100%', height: '120%' }}/>
<BiometricPopup { this.state.sensorInfo && <BiometricPopup
dispatch={this.props.dispatch}
themeId={this.props.themeId} themeId={this.props.themeId}
sensorInfo={this.state.sensorInfo} sensorInfo={this.state.sensorInfo}
/> /> }
</SafeAreaView> </SafeAreaView>
</MenuContext> </MenuContext>
</SideMenu> </SideMenu>
@ -1017,6 +1023,7 @@ const mapStateToProps = (state: any) => {
routeName: state.route.routeName, routeName: state.route.routeName,
themeId: state.settings.theme, themeId: state.settings.theme,
noteSideMenuOptions: state.noteSideMenuOptions, noteSideMenuOptions: state.noteSideMenuOptions,
biometricsDone: state.biometricsDone,
}; };
}; };

View File

@ -79,6 +79,7 @@ export interface State {
settings: any; settings: any;
sharedData: any; sharedData: any;
appState: string; appState: string;
biometricsDone: boolean;
hasDisabledSyncItems: boolean; hasDisabledSyncItems: boolean;
hasDisabledEncryptionItems: boolean; hasDisabledEncryptionItems: boolean;
customCss: string; customCss: string;
@ -134,6 +135,7 @@ export const defaultState: State = {
settings: {}, settings: {},
sharedData: null, sharedData: null,
appState: 'starting', appState: 'starting',
biometricsDone: false,
hasDisabledSyncItems: false, hasDisabledSyncItems: false,
hasDisabledEncryptionItems: false, hasDisabledEncryptionItems: false,
customCss: '', customCss: '',
@ -1086,6 +1088,10 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
draft.appState = action.state; draft.appState = action.state;
break; break;
case 'BIOMETRICS_DONE_SET':
draft.biometricsDone = action.value;
break;
case 'SYNC_HAS_DISABLED_SYNC_ITEMS': case 'SYNC_HAS_DISABLED_SYNC_ITEMS':
draft.hasDisabledSyncItems = true; draft.hasDisabledSyncItems = true;
break; break;