1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-12 08:54:00 +02:00
joplin/packages/app-mobile/utils/ShareExtension.ts
2022-10-23 14:00:27 +01:00

26 lines
842 B
TypeScript

import debounce from './debounce';
const { NativeModules, Platform } = require('react-native');
export interface SharedData {
title?: string;
text?: string;
resources?: string[];
}
const ShareExtension = (NativeModules.ShareExtension) ?
{
data: () => NativeModules.ShareExtension.data(),
// we debounce the `close` method, to keep alive permissions of Uris received from the share activity
// this is to prevent getting permission denied error while sharing the same file to joplin multiple times in a row
close: () => debounce(() => NativeModules.ShareExtension.close(), 3 * 60 * 1000), // close it after 3 minutes
shareURL: (Platform.OS === 'ios') ? NativeModules.ShareExtension.getConstants().SHARE_EXTENSION_SHARE_URL : '',
} :
{
data: () => {},
close: () => {},
shareURL: '',
};
export default ShareExtension;