diff --git a/app/components/file_attachment_list/file_attachment_document.js b/app/components/file_attachment_list/file_attachment_document.js index 91b4398ac..87c147665 100644 --- a/app/components/file_attachment_list/file_attachment_document.js +++ b/app/components/file_attachment_list/file_attachment_document.js @@ -66,13 +66,14 @@ export default class FileAttachmentDocument extends PureComponent { state = { didCancel: false, downloading: false, + preview: false, progress: 0, }; componentDidMount() { this.mounted = true; this.eventEmitter = new NativeEventEmitter(NativeModules.RNReactNativeDocViewer); - this.eventEmitter.addListener('DoneButtonEvent', () => this.setStatusBarColor()); + this.eventEmitter.addListener('DoneButtonEvent', this.onDonePreviewingFile); } componentWillUnmount() { @@ -223,15 +224,21 @@ export default class FileAttachmentDocument extends PureComponent { }, delay); }; + onDonePreviewingFile = () => { + this.setState({preview: false}); + this.setStatusBarColor(); + }; + openDocument = (file, delay = 2000) => { // The animation for the progress circle takes about 2 seconds to finish // therefore we are delaying the opening of the document to have the UI // shown nicely and smooth setTimeout(() => { - if (!this.state.didCancel && this.mounted) { + if (!this.state.didCancel && !this.state.preview && this.mounted) { const {data} = file; const prefix = Platform.OS === 'android' ? 'file:/' : ''; const path = `${DOCUMENTS_PATH}/${data.id}-${file.caption}`; + this.setState({preview: true}); this.setStatusBarColor('dark-content'); OpenFile.openDoc([{ url: `${prefix}${path}`,