MM-17886 Do not wait to cancel the video download (#3164)

This commit is contained in:
Elias Nahum 2019-08-22 15:47:06 -04:00 committed by Harrison Healey
parent c76f12647a
commit d5338f5e39

View file

@ -282,19 +282,16 @@ export default class Downloader extends PureComponent {
if (this.mounted) {
this.setState({
progress: 100,
}, () => {
// need to wait a bit for the progress circle UI to update to the give progress
setTimeout(async () => {
if (this.state.didCancel) {
try {
await RNFetchBlob.fs.unlink(path);
} finally {
this.props.onDownloadCancel();
}
} else {
this.props.onDownloadSuccess();
}, async () => {
if (this.state.didCancel) {
try {
await RNFetchBlob.fs.unlink(path);
} finally {
this.downloadDidCancel();
}
}, 2000);
} else {
this.props.onDownloadSuccess();
}
});
}
@ -306,7 +303,9 @@ export default class Downloader extends PureComponent {
} catch (error) {
// cancellation throws so we need to catch
if (downloadPath) {
RNFetchBlob.fs.unlink(getLocalFilePathFromFile(downloadPath, file));
RNFetchBlob.fs.unlink(getLocalFilePathFromFile(downloadPath, file)).catch(() => {
// do nothing
});
}
if (error.message !== 'cancelled' && this.mounted) {
this.showDownloadFailedAlert();