import ShareExtension , { SharedData } from './ShareExtension' ; import shim from '@joplin/lib/shim' ; import Note from '@joplin/lib/models/Note' ; import checkPermissions from './checkPermissions.js' ; const { ToastAndroid } = require ( 'react-native' ) ; const { PermissionsAndroid } = require ( 'react-native' ) ; const { Platform } = require ( 'react-native' ) ; export default async ( sharedData , folderId , dispatch ) => { if ( ! ! sharedData . resources && sharedData . resources . length > 0 ) { if ( Platform . OS === 'android' ) { const response = await checkPermissions ( PermissionsAndroid . PERMISSIONS . READ_EXTERNAL_STORAGE ) ; if ( response !== PermissionsAndroid . RESULTS . GRANTED ) { ToastAndroid . show ( 'Cannot receive shared data - permission denied' , ToastAndroid . SHORT ) ; ShareExtension . close ( ) ; return ; } } } dispatch ( { type : 'NAV_BACK' } ) ; 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 , } ) ; } , 5 ) ; } ;