From 75c7f76c1f70b3796ef8aa9e96313767ecf510a0 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Wed, 5 Feb 2020 13:41:40 -0300 Subject: [PATCH] [FIX] In some cases, share extension doesn't load images (#1649) --- app/views/ShareListView/index.js | 48 +++++++++++++++++--------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/app/views/ShareListView/index.js b/app/views/ShareListView/index.js index ee500231c..bb254c421 100644 --- a/app/views/ShareListView/index.js +++ b/app/views/ShareListView/index.js @@ -114,7 +114,7 @@ class ShareListView extends React.Component { this.willBlurListener = props.navigation.addListener('willBlur', () => BackHandler.addEventListener('hardwareBackPress', this.handleBackPress)); } - async componentDidMount() { + componentDidMount() { const { navigation, server } = this.props; navigation.setParams({ initSearch: this.initSearch, @@ -122,30 +122,32 @@ class ShareListView extends React.Component { search: this.search }); - try { - const { value, type } = await ShareExtension.data(); - let fileInfo = null; - const isMedia = (type === 'media'); - if (isMedia) { - this.setState({ mediaLoading: true }); - const data = await RNFetchBlob.fs.stat(this.uriToPath(value)); - fileInfo = { - name: data.filename, - description: '', - size: data.size, - mime: mime.lookup(data.path), - path: isIOS ? data.path : `file://${ data.path }` - }; + setTimeout(async() => { + try { + const { value, type } = await ShareExtension.data(); + let fileInfo = null; + const isMedia = (type === 'media'); + if (isMedia) { + this.setState({ mediaLoading: true }); + const data = await RNFetchBlob.fs.stat(this.uriToPath(value)); + fileInfo = { + name: data.filename, + description: '', + size: data.size, + mime: mime.lookup(data.path), + path: isIOS ? data.path : `file://${ data.path }` + }; + } + this.setState({ + value, fileInfo, isMedia, mediaLoading: false + }); + } catch (e) { + log(e); + this.setState({ mediaLoading: false }); } - this.setState({ - value, fileInfo, isMedia, mediaLoading: false - }); - } catch (e) { - log(e); - this.setState({ mediaLoading: false }); - } - this.getSubscriptions(server); + this.getSubscriptions(server); + }, 500); } componentWillReceiveProps(nextProps) {