1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Android: Fixes #11324: Fix sharing to Joplin causes back navigation to get stuck (#11355)

This commit is contained in:
Henry Heino
2024-11-09 04:54:09 -08:00
committed by GitHub
parent 0876086caa
commit a08ebb9ce5
5 changed files with 29 additions and 18 deletions

View File

@ -3,6 +3,7 @@ import shim from '@joplin/lib/shim';
import Note from '@joplin/lib/models/Note';
import checkPermissions from './checkPermissions.js';
import NavService from '@joplin/lib/services/NavService';
const { ToastAndroid } = require('react-native');
const { PermissionsAndroid } = require('react-native');
const { Platform } = require('react-native');
@ -27,27 +28,21 @@ export default async (sharedData: SharedData, folderId: string, dispatch: Functi
}
}
const newNote = await Note.save({
parent_id: folderId,
}, { provisional: true });
// This is a bit hacky, but the surest way to go to
// the needed note. We go back one screen in case there's
// already a note open - if we don't do this, the dispatch
// below will do nothing (because routeName wouldn't change)
// Then we wait a bit for the state to be set correctly, and
// finally we go to the new note.
dispatch({ type: 'NAV_BACK' });
await NavService.go('Notes', { folderId, clearHistory: true });
dispatch({ type: 'SIDE_MENU_CLOSE' });
const newNote = await Note.save({
parent_id: folderId,
}, { provisional: true });
shim.setTimeout(() => {
dispatch({
type: 'NAV_GO',
routeName: 'Note',
noteId: newNote.id,
sharedData: sharedData,
});
shim.setTimeout(async () => {
await NavService.go('Note', { noteId: newNote.id, sharedData });
ShareExtension.close();
}, 5);