MM-13665 Prevent quick multiple taps on file to open multiple file previews (#2503)
This commit is contained in:
parent
2e47074bbd
commit
e1853c6682
1 changed files with 9 additions and 2 deletions
|
|
@ -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}`,
|
||||
|
|
|
|||
Loading…
Reference in a new issue