2022-10-23 15:00:27 +02:00
|
|
|
import debounce from './debounce';
|
|
|
|
|
2020-06-04 19:40:44 +02:00
|
|
|
const { NativeModules, Platform } = require('react-native');
|
|
|
|
|
|
|
|
export interface SharedData {
|
2020-11-12 21:29:22 +02:00
|
|
|
title?: string;
|
|
|
|
text?: string;
|
|
|
|
resources?: string[];
|
2020-06-04 19:40:44 +02:00
|
|
|
}
|
|
|
|
|
2021-04-24 10:22:11 +02:00
|
|
|
const ShareExtension = (NativeModules.ShareExtension) ?
|
2020-06-04 19:40:44 +02:00
|
|
|
{
|
|
|
|
data: () => NativeModules.ShareExtension.data(),
|
2022-10-23 15:00:27 +02:00
|
|
|
// 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 : '',
|
2020-06-04 19:40:44 +02:00
|
|
|
} :
|
|
|
|
{
|
|
|
|
data: () => {},
|
|
|
|
close: () => {},
|
2021-04-24 10:22:11 +02:00
|
|
|
shareURL: '',
|
2020-06-04 19:40:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default ShareExtension;
|