[FIX] In some cases, share extension doesn't load images (#1649)

This commit is contained in:
Diego Mello 2020-02-05 13:41:40 -03:00 committed by GitHub
parent 98f12bc058
commit 75c7f76c1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 23 deletions

View File

@ -114,7 +114,7 @@ class ShareListView extends React.Component {
this.willBlurListener = props.navigation.addListener('willBlur', () => BackHandler.addEventListener('hardwareBackPress', this.handleBackPress)); this.willBlurListener = props.navigation.addListener('willBlur', () => BackHandler.addEventListener('hardwareBackPress', this.handleBackPress));
} }
async componentDidMount() { componentDidMount() {
const { navigation, server } = this.props; const { navigation, server } = this.props;
navigation.setParams({ navigation.setParams({
initSearch: this.initSearch, initSearch: this.initSearch,
@ -122,30 +122,32 @@ class ShareListView extends React.Component {
search: this.search search: this.search
}); });
try { setTimeout(async() => {
const { value, type } = await ShareExtension.data(); try {
let fileInfo = null; const { value, type } = await ShareExtension.data();
const isMedia = (type === 'media'); let fileInfo = null;
if (isMedia) { const isMedia = (type === 'media');
this.setState({ mediaLoading: true }); if (isMedia) {
const data = await RNFetchBlob.fs.stat(this.uriToPath(value)); this.setState({ mediaLoading: true });
fileInfo = { const data = await RNFetchBlob.fs.stat(this.uriToPath(value));
name: data.filename, fileInfo = {
description: '', name: data.filename,
size: data.size, description: '',
mime: mime.lookup(data.path), size: data.size,
path: isIOS ? data.path : `file://${ data.path }` 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) { componentWillReceiveProps(nextProps) {