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

26 lines
842 B
TypeScript
Raw Normal View History

import debounce from './debounce';
const { NativeModules, Platform } = require('react-native');
export interface SharedData {
title?: string;
text?: string;
resources?: string[];
}
2021-04-24 10:22:11 +02:00
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
2021-04-24 10:22:11 +02:00
shareURL: (Platform.OS === 'ios') ? NativeModules.ShareExtension.getConstants().SHARE_EXTENSION_SHARE_URL : '',
} :
{
data: () => {},
close: () => {},
2021-04-24 10:22:11 +02:00
shareURL: '',
};
export default ShareExtension;